Repository navigation
feat(harbor): load .env for StirrupAgent credentials - #575
Merged
Merged
Conversation
StirrupAgent now loads the nearest .env above the working directory before checking router credentials, so tokenrouter/ and litellm_proxy/ models run without exporting their variables. override=False keeps exported variables and --ae ahead of the file, and only CREDENTIAL_ENV_VARS reach the container. Tests chdir into tmp_path so a developer's .env cannot leak in, and the credential fixture now restores variables that load_dotenv writes. Signed-off-by: Shuxin Lin <linshuhsin@gmail.com>
7 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
StirrupAgentnow loads the nearest.envabove the working directory before it checks router credentials.uv run harbor run ... --model tokenrouter/MiniMax-M3then works from the repo root without exportingTOKENROUTER_BASE_URL/TOKENROUTER_API_KEY.--ae KEY=VALUE, then exported shell variables, then.env. The file is loaded withoverride=False, so it never replaces a variable that is already set.CREDENTIAL_ENV_VARSare forwarded into the agent container, and.dockerignorestill keeps.envout of every image.[verifier].envtemplates at verify time (harbor/verifier/verifier.py), after the agent is constructed, soAOB_JUDGE_MODELand the judge keys are also picked up from.env.--agent oraclenever constructsStirrupAgent, so it does not load.env. Use--env-file .envthere if a scenario needs a judge. This is documented in the README.Stacked on #558. It targets
feature/harbor-integrationbecausesrc/assetops_harbor/is not onmainyet.Type of Change
Industry Relevance
None directly. This only affects how credentials reach Harbor runs.
Related Issues
Testing & Validation
uv run pytest src/assetops_harborpasses (19 passed, 2 new):test_router_credentials_from_dotenv_satisfy_the_checktest_exported_variables_win_over_dotenvThe test changes:
chdirs intotmp_path, so a developer's own.envcannot leak into the adapter tests.no_router_credentialsnow doessetenvthendelenv, so teardown also removes variables thatload_dotenvwrites during a test.The full suite (
uv run pytest src/ -k "not integration") has 19 failures, all outside this change. The same 19 fail with--ignore=src/assetops_harbor:servers/iot/tests/test_tools.py(11),evaluation/tests/test_static_json_scorer.py(6),observability/tests/test_file_exporter.py(2).Checklist