Skip to content

fix(loop): only mention the expanded retry in runaway guidance when it ran - #46

Open
zhanghanduo wants to merge 1 commit into
mainfrom
fix/runaway-guidance-without-expansion
Open

zhanghanduo wants to merge 1 commit into
mainfrom
fix/runaway-guidance-without-expansion

Conversation

@zhanghanduo

Copy link
Copy Markdown
Collaborator

Summary

Runaway recovery is a ladder: expanded thinking → reduced thinking → thinking off. The first phase is skipped when RUNAWAY_MAX_RETRIES < 3 (_RUNAWAY_EXPAND_ENABLED is false) or when the expanded cap cannot fit the context. In both cases the first retry goes straight to the reduced phase, but its reminder still said:

The expanded-thinking retry still produced no visible answer or tool call…

so the model was told about an attempt it never saw.

call_llm now records whether an expanded retry actually ran (runaway_expanded) and passes it to _runaway_retry_policy(..., expanded_attempted=...). The reduced phase uses the existing reminder after a real expanded retry (including the context-overflow path, where the expanded attempt did run), and a new _RUNAWAY_REDUCED_GUIDANCE otherwise, which carries the same instruction without referring to a phase that never ran. The keyword defaults to True, so other callers keep today's behaviour. Retry counts, caps and thinking overrides are unchanged.

Found while migrating FrontierAgent onto AgentCore (ApodexAI/FrontierAgent#50), where *_RUNAWAY_MAX_RETRIES=2 is the documented way to keep cap-only retries.

Test plan

  • New tests/test_runaway_retry_guidance.py:
    • policy-level: the reduced reminder mentions the expanded retry only when expanded_attempted=True;
    • end-to-end through call_llm with expansion disabled: the retry request's reminder does not mention an expanded retry.
    • Both fail on main, pass with the fix.
  • Release fragment changes/runaway-guidance-without-expansion.fix.md; check_version_bump.py passes
  • ruff, pyright agent_core, full pytest -q (1603 passed)

🤖 Generated with Claude Code

…t ran

With expansion disabled by a lowered RUNAWAY_MAX_RETRIES, or skipped because
it could not fit the context, the first runaway retry goes straight to the
reduced phase, yet its reminder said "The expanded-thinking retry still
produced no visible answer" -- describing an attempt the model never saw.
call_llm now tracks whether an expanded retry actually ran and the reduced
phase picks its reminder accordingly. Retry ladder, caps and thinking
overrides are unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant