Conversation
|
This is the right shape and it's complete — verified both halves:
Worth flagging for the maintainer: this is exactly the pattern the still-open #32007 (reload |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for addressing both the constructor snapshot and cached-agent path; current main still has the reported gap: gateway/run.py:13383 and gateway/run.py:18032 read the startup self._provider_routing, while gateway/run.py:18158-18163 builds the cache signature without routing fields.
Problems
- The new refresh helper would retain a configuration-source mismatch.
gateway/run.py:4982-4993loads raw YAML, but the gateway’s effective config path applies the managed-scope overlay atgateway/run.py:2352-2359. The PR should not construct an agent from raw routing while calculating its cache signature from effectiveuser_config.
Suggested changes
- Thread effective
user_config["provider_routing"]through both construction paths, validate it as a dict, and use that same value for cache invalidation. Add coverage for the effective/managed configuration path.
Automated hermes-sweeper review.
| disabled_toolsets = agent_cfg.get("disabled_toolsets") or None | ||
|
|
||
| pr = self._provider_routing | ||
| pr = self._refresh_provider_routing() |
There was a problem hiding this comment.
Use the effective user_config already loaded above for this refresh. _load_provider_routing() reads raw YAML, while _load_gateway_config() applies managed scope; otherwise the new routing passed to AIAgent can disagree with the routing values used in the cache signature.
Summary
Reload
provider_routingat agent construction time so live config edits take effect on the next turn, and include routing fields in the gateway agent cache signature so stale agents are not reused after routing changes.Why
The gateway was holding on to the startup routing snapshot, which meant config edits could leave subsequent turns using an outdated OpenRouter routing policy.
Testing
62 passedtest_provider_routing_change_busts_cachetest_reads_provider_routing_subkeystest_run_agent_reloads_provider_routing_and_busts_cached_agenttest_agent_cache.pytest_session_model_override_routing.py