Skip to content

fix(config): reload .env over stale shell overrides#1434

Merged
teknium1 merged 1 commit intomainfrom
fix/1244-env-override
Mar 15, 2026
Merged

fix(config): reload .env over stale shell overrides#1434
teknium1 merged 1 commit intomainfrom
fix/1244-env-override

Conversation

@teknium1
Copy link
Contributor

@teknium1 teknium1 commented Mar 15, 2026

Summary

  • load Hermes env files through a shared helper that lets ~/.hermes/.env override stale shell-exported values on restart
  • preserve user env over project fallback while still letting the project .env fill missing values in dev setups
  • wire the shared loader into the main startup entrypoints and add regression coverage for the reported stale-BASE_URL/provider case

Root cause

I reproduced the issue directly on current main:

  • shell had stale OPENAI_BASE_URL=https://old.example/v1
  • ~/.hermes/.env contained OPENAI_BASE_URL=https://new.example/v1 and HERMES_INFERENCE_PROVIDER=custom
  • importing hermes_cli.main left the old shell values in place because the startup dotenv loads were using the default override=False

That meant editing .env and restarting Hermes could still leave the process pinned to old model/provider/base_url settings if those vars were already exported in the parent shell.

Test plan

  • source .venv/bin/activate && python -m pytest tests/hermes_cli/test_env_loader.py tests/test_runtime_provider_resolution.py -n0 -q
  • source .venv/bin/activate && python -m pytest tests/test_cli_provider_resolution.py tests/hermes_cli/ -n0 -q
  • source .venv/bin/activate && python -m pytest tests/gateway/ -n0 -q
  • source .venv/bin/activate && python -m pytest tests/ -n0 -q # one unrelated existing full-suite failure remains: tests/test_api_key_providers.py::TestResolveProvider::test_auto_detects_minimax_cn_key

Verification

  • PYTHONPATH=. python /tmp/repro1244.py now prints the updated values from the Hermes user env file instead of the stale shell exports

Hermes startup entrypoints now load ~/.hermes/.env and project fallback env files with user config taking precedence over stale shell-exported values. This makes model/provider/base URL changes in .env actually take effect after restarting Hermes. Adds a shared env loader plus regression coverage, and reproduces the original bug case where OPENAI_BASE_URL and HERMES_INFERENCE_PROVIDER remained stuck on old shell values before import.
@teknium1 teknium1 merged commit 77bfa25 into main Mar 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant