Conversation
Clear stale model.context_length overrides when switching models or providers so custom endpoint context values do not leak globally. Co-authored-by: Hermes Agent <hermes-agent@users.noreply.github.com>
|
Note: PR #24724 (merged 2026-05-13) is the authoritative fix for clearing stale |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for isolating the persisted-config path; the underlying issue remains on current main.
Problems
- The implementation needs a conflict-aware salvage: the changed
_model_flow_custom,_model_flow_named_custom, and_model_flow_api_key_providerfunctions were extracted fromhermes_cli/main.pyintohermes_cli/model_setup_flows.pybya77efada5. Current custom setup still preserves the stale value athermes_cli/model_setup_flows.py:947-960, so the oldmain.pyhunks do not affect the live flow. - The new regression test stubs
_save_model_choiceattests/cli/test_cli_provider_resolution.py:564, but the PR changes that helper athermes_cli/auth.py:5148. It does not cover that central mutation.
Suggested changes
- Port the cleanup to the extracted flow and add a test using the real save path. Assert the active
model.context_lengthis cleared whilecustom_providers[].models.<model>.context_lengthremains intact; runtime precedence is visible inagent/agent_init.py:1660-1708.
Automated hermes-sweeper review.
| "hermes_cli.config.get_env_value", | ||
| lambda key: "" if key in {"OPENAI_BASE_URL", "OPENAI_API_KEY"} else "", | ||
| ) | ||
| monkeypatch.setattr("hermes_cli.auth._save_model_choice", lambda model: None) |
There was a problem hiding this comment.
This stubs the helper changed in hermes_cli/auth.py:5148, so the regression does not exercise that central cleanup. Keep this flow test if it validates the explicit flow cleanup, but add a separate real _save_model_choice assertion for the helper behavior.
Summary
model.context_lengthglobal overrides when switching models/providers.Credit: this fix was implemented with Hermes Agent.
Why
model.context_lengthis a global runtime override. If a custom endpoint setup leftcontext_length: 64000in the globalmodel:block, every provider selected afterward could inherit that 64k limit, including Codex, OpenAI, Anthropic, and other non-custom providers.The custom provider wizard should preserve context length only as provider/model metadata, not as a global model override.
Testing
scripts/run_tests.sh tests/cli/test_cli_provider_resolution.py tests/hermes_cli/test_custom_provider_model_switch.py tests/hermes_cli/test_model_switch_custom_providers.py tests/hermes_cli/test_user_providers_model_switch.py -q79 passedCo-authored-by: Hermes Agent hermes-agent@users.noreply.github.com