Skip to content

fix: honor gateway agent max turns config - #17306

Closed
kchuang1015 wants to merge 1 commit into
NousResearch:mainfrom
kchuang1015:fix/gateway-agent-max-turns-config
Closed

fix: honor gateway agent max turns config#17306
kchuang1015 wants to merge 1 commit into
NousResearch:mainfrom
kchuang1015:fix/gateway-agent-max-turns-config

Conversation

@kchuang1015

Copy link
Copy Markdown
Contributor

Summary

  • Resolve gateway-created agent max iterations from config first (agent.max_turns, then legacy top-level max_turns)
  • Keep HERMES_MAX_ITERATIONS as a legacy fallback only
  • Prevent stale dotenv reloads from overriding the configured gateway loop limit

Test Plan

  • python3 -m pytest -q tests/gateway/test_agent_max_turns_config.py
  • python3 -m py_compile gateway/run.py tests/gateway/test_agent_max_turns_config.py

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery area/config Config system, migrations, profiles labels Apr 29, 2026
@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Closing as already resolved on current main.

The config-authority contract this PR restores is already in place in gateway/run.py:

  • _reload_runtime_env_preserving_config_authority() reloads .env for fresh credentials but explicitly preserves config.yaml's agent.max_turns so a stale HERMES_MAX_ITERATIONS in .env can't override it on later turns.
  • _bridge_max_turns_from_config() bridges config.yaml agent.max_turns into the env var, and the startup bridge guards the "stale 60 vs configured 500" regression.
  • _current_max_iterations() re-reads the budget per turn after that refresh.

So a stale HERMES_MAX_ITERATIONS=90 no longer wins over a higher configured agent.max_turns. Thanks for the fix and the clear write-up of the regression — the contract you wanted is honored on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants