fix(gateway): refresh runtime max_turns before agent creation - #48127
fix(gateway): refresh runtime max_turns before agent creation#48127infinitycrew39 wants to merge 4 commits into
Conversation
|
Related: #32544 — both fix stale |
When a gateway agent is reused from cache, it retains the max_iterations from its initial creation. If config.yaml agent.max_turns or HERMES_MAX_ITERATIONS changed between turns, the cached agent's budget becomes stale. Before reusing a cached agent, refresh agent.max_iterations from the freshly-resolved value (read from env/config at line 14585). Fixes partial issue from PR NousResearch#48127: handles fresh agent creation + cached agent reuse.
Add 5 test cases covering: - Cached agent max_iterations refreshed from HERMES_MAX_ITERATIONS env - Refresh works even for interrupt-recursive turns (depth > 0) - Session state is preserved during refresh - Integration: env config changes propagate to cached agent on reuse Tests can be run via: scripts/run_tests.sh tests/gateway/test_cached_agent_max_iterations.py Fix: correct static method access in fixture (remove __func__)
5f83677 to
6915c9a
Compare
When a gateway agent is reused from cache, it retains the max_iterations from its initial creation. If config.yaml agent.max_turns or HERMES_MAX_ITERATIONS changed between turns, the cached agent's budget becomes stale. Before reusing a cached agent, refresh agent.max_iterations from the freshly-resolved value (read from env/config at line 14585). Fixes partial issue from PR #48127: handles fresh agent creation + cached agent reuse.
|
Merged via PR #48834 — your two fix commits were cherry-picked onto current main with your authorship preserved (rebase-merge). The tautological cached-agent test was swapped for one that exercises the real contracts. Live-validated against origin/main: a cache-reused agent was stuck at 90 despite config.yaml max_turns=200; the fix refreshes it to 200. Thanks for the fix and the clear root-cause writeup! #48834 |
When a gateway agent is reused from cache, it retains the max_iterations from its initial creation. If config.yaml agent.max_turns or HERMES_MAX_ITERATIONS changed between turns, the cached agent's budget becomes stale. Before reusing a cached agent, refresh agent.max_iterations from the freshly-resolved value (read from env/config at line 14585). Fixes partial issue from PR NousResearch#48127: handles fresh agent creation + cached agent reuse.
When a gateway agent is reused from cache, it retains the max_iterations from its initial creation. If config.yaml agent.max_turns or HERMES_MAX_ITERATIONS changed between turns, the cached agent's budget becomes stale. Before reusing a cached agent, refresh agent.max_iterations from the freshly-resolved value (read from env/config at line 14585). Fixes partial issue from PR NousResearch#48127: handles fresh agent creation + cached agent reuse.
When a gateway agent is reused from cache, it retains the max_iterations from its initial creation. If config.yaml agent.max_turns or HERMES_MAX_ITERATIONS changed between turns, the cached agent's budget becomes stale. Before reusing a cached agent, refresh agent.max_iterations from the freshly-resolved value (read from env/config at line 14585). Fixes partial issue from PR NousResearch#48127: handles fresh agent creation + cached agent reuse.
When a gateway agent is reused from cache, it retains the max_iterations from its initial creation. If config.yaml agent.max_turns or HERMES_MAX_ITERATIONS changed between turns, the cached agent's budget becomes stale. Before reusing a cached agent, refresh agent.max_iterations from the freshly-resolved value (read from env/config at line 14585). Fixes partial issue from PR NousResearch#48127: handles fresh agent creation + cached agent reuse.
When a gateway agent is reused from cache, it retains the max_iterations from its initial creation. If config.yaml agent.max_turns or HERMES_MAX_ITERATIONS changed between turns, the cached agent's budget becomes stale. Before reusing a cached agent, refresh agent.max_iterations from the freshly-resolved value (read from env/config at line 14585). Fixes partial issue from PR NousResearch#48127: handles fresh agent creation + cached agent reuse.
When a gateway agent is reused from cache, it retains the max_iterations from its initial creation. If config.yaml agent.max_turns or HERMES_MAX_ITERATIONS changed between turns, the cached agent's budget becomes stale. Before reusing a cached agent, refresh agent.max_iterations from the freshly-resolved value (read from env/config at line 14585). Fixes partial issue from PR NousResearch#48127: handles fresh agent creation + cached agent reuse.
What does this PR do?
This PR fixes a runtime budget bug where long-lived gateway and api_server processes could continue using a stale 90-turn iteration cap even after
agent.max_turnswas increased inconfig.yaml.The root cause was that some request paths read
HERMES_MAX_ITERATIONSbefore refreshing the config-authoritative runtime env, whileapi_serverbypassed that refresh path entirely.Type of Change
Changes Made
gateway/run.pythat refreshes config/.env before resolving the current iteration budget.gateway/platforms/api_server.pyto use the same helper instead of reading a stale env snapshot directly.How to Test
HERMES_MAX_ITERATIONS=90.agent.max_turns: 200in~/.hermes/config.yamlwithout restarting the process.Notes
Targeted pytest execution was not possible in this workspace because no project virtualenv is present; modified files were validated with
python3 -m py_compile.