fix(loop): only mention the expanded retry in runaway guidance when it ran - #46
Open
zhanghanduo wants to merge 1 commit into
Open
zhanghanduo wants to merge 1 commit into
zhanghanduo wants to merge 1 commit into
Conversation
…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>
6 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Runaway recovery is a ladder: expanded thinking → reduced thinking → thinking off. The first phase is skipped when
RUNAWAY_MAX_RETRIES < 3(_RUNAWAY_EXPAND_ENABLEDis 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:so the model was told about an attempt it never saw.
call_llmnow 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_GUIDANCEotherwise, which carries the same instruction without referring to a phase that never ran. The keyword defaults toTrue, 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=2is the documented way to keep cap-only retries.Test plan
tests/test_runaway_retry_guidance.py:expanded_attempted=True;call_llmwith expansion disabled: the retry request's reminder does not mention an expanded retry.main, pass with the fix.changes/runaway-guidance-without-expansion.fix.md;check_version_bump.pypassesruff,pyright agent_core, fullpytest -q(1603 passed)🤖 Generated with Claude Code