fix(gateway): reload fallback chain when config changes - #39022
Closed
Que0x wants to merge 1 commit into
Closed
Conversation
Contributor
|
Thanks for the careful fallback-chain/cache analysis. This is an automated hermes-sweeper review; current
Closing as implemented on main. |
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.
What & why
The gateway loaded the fallback provider chain once at
__init__(
self._fallback_model) and never refreshed it. The agent-cache signaturealso omitted the chain, so an operator who edited
fallback_providers/fallback_modelinconfig.yamlkept getting routed on the stale chain —even on a brand-new session — until a full gateway restart. This contradicts
the documented "changes take effect on the next agent session or gateway
restart" contract (
web-dashboard.md), and means a provider auth/rate-limitfix doesn't actually take hold.
How
All changes in
gateway/run.py:_load_fallback_model(cfg=None)— accepts a pre-loaded config so thechain can be re-resolved from the current turn's config (no extra disk read).
Backward compatible; the
__init__call is unchanged._extract_cache_busting_config— folds the effective merged chain(
fallback.chain) into the agent-cache signature, so a change rebuilds thecached agent and an unchanged chain causes no cache churn.
_run_agent/_run_background_task— re-resolveself._fallback_modelfrom the freshly-loadeduser_configbefore buildingthe agent.
Legacy
fallback_model+fallback_providersmerge semantics are preserved(
get_fallback_chain). No behavior change for users without a fallback config(empty chain →
None).How to test
Tests & results
test_agent_cache.py+test_auth_fallback.py+test_session_model_override_routing.pyTestFallbackChainCacheBusting(regression)test_background_command.py(covers edited_run_background_task)New regression tests assert: signature busts when the chain changes,
stays stable when unchanged (no churn), legacy
fallback_modelmerge ispreserved, and
_load_fallback_model(cfg)resolves from a passed config.