fix: move _last_content_with_tools fallback after retry mechanisms#8024
fix: move _last_content_with_tools fallback after retry mechanisms#8024tomqiaozc wants to merge 1 commit into
Conversation
The _last_content_with_tools fallback was firing before empty-response retries (thinking-prefill, empty-content, fallback provider), causing the agent to silently terminate mid-task with stale content instead of retrying. Move the fallback to after all retry mechanisms are exhausted so it only fires as a true last resort. Also clear stale _last_content_with_tools on tool-only turns to prevent old content from persisting across many turns. Fixes NousResearch#7968 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Thanks for the thorough write-up and repro in #7968, @tomqiaozc — this is a real and well-documented bug. However, the core issue was independently fixed on The secondary fix (clearing stale Evidence:
Note: your three This is an automated hermes-sweeper review. |
Summary
_last_content_with_toolsfallback to fire after all retry mechanisms (thinking-prefill retry, empty-content retry ×3, fallback provider), instead of before them. Previously the fallback short-circuited retries, causing silent mid-task termination with stale content._last_content_with_toolson tool-only turns (no real content) to prevent old content from persisting across many turns.Fixes #7968
Test plan
TestLastContentWithToolsFallback::test_retries_before_fallback_on_empty_followup— verifies retries produce fresh content before fallback is consultedTestLastContentWithToolsFallback::test_fallback_used_after_all_retries_exhausted— verifies fallback IS used when all retries return emptyTestLastContentWithToolsFallback::test_stale_fallback_cleared_on_tool_only_turn— verifies tool-only turn clears stale capturetest_run_agent.pysuite: 251/251 passed🤖 Generated with Claude Code