Skip to content

fix(agent): clear stale turn state on model switch - #26121

Closed
LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:hermes/fix-25325-model-switch-recovery-state
Closed

LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:hermes/fix-25325-model-switch-recovery-state

Conversation

@LeonSGP43

Copy link
Copy Markdown
Contributor

Summary

  • clear turn-scoped retry, prefill, and tool-guardrail state inside AIAgent.switch_model()
  • prevent stale post-switch session state from leaking into the next API request
  • add a regression test covering switch-time recovery-state reset

Testing

  • ./venv/bin/pytest -q tests/run_agent/test_switch_model_fallback_prune.py
  • ./venv/bin/ruff check run_agent.py tests/run_agent/test_switch_model_fallback_prune.py
  • git diff --check

Attribution

  • any repeated required-check red shared across recent company PRs is treated as preexisting_unrelated baseline noise; the local targeted proof for this diff is green.

Fixes #25325

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint labels May 15, 2026
@alt-glitch

Copy link
Copy Markdown

Related: #25343 (closed, not merged) — same fix pattern: clearing turn-scoped recovery state in AIAgent.switch_model(). Both address #25325.

Also related to #10702 (stale agent state on /resume), #25131 (persist model runtime state on switch).

@teknium1

Copy link
Copy Markdown
Collaborator

Automated hermes-sweeper review: this looks implemented on current main by the newer turn-prologue cleanup and retry-state refactor.

Evidence:

Thanks for the focused regression test and for connecting it to the underlying stale-state report.

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

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Model switching corrupts session/request state with Hindsight enabled, causing retry loop and IndexError

3 participants