feat: auto-continue after max-iteration exhaustion#31418
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the bounded, config-gated continuation design and the retry/undo coverage. The feature remains relevant: current main still moves exhausted turns to the tool-less summary fallback in agent/turn_finalizer.py:82-97.
Problems
agent/chat_completion_helpers.py:127appends the continuation as ausermessage. After a tool-calling iteration exhausts the budget, the tail can betool → user. Current main explicitly repairs that malformed shape before requests (agent/conversation_loop.py:773-790), and documents strict-provider failures for it inagent/message_sanitization.py:282-311. Existing synthetic continuations preserve alternation by first appending an assistant turn (agent/conversation_loop.py:4927-4944).- The loop was refactored after this branch: budget initialization now lives in
agent/turn_context.py:222-259, while exhaustion fallback and completion semantics live inagent/turn_finalizer.py:54-157. The counter reset needs to be reworked through those seams.
Suggested changes
- Rebase the implementation concept onto the current continuation/finalization seams, preserving a valid assistant/tool/user sequence before the next API request, and test an exhausted tool-result tail.
- Keep total versus per-cycle API-call accounting explicit through
finalize_turn.
Automated hermes-sweeper review.
|
Current-main remediation pushed at What changed:
Verification on the final tree merged onto current
|
|
Final current-main sync: head |
|
@teknium1 current-main merge blocker is resolved on exact head
Please re-review the current head if the branch still looks useful on top of current |
d51a630 to
f015077
Compare
Summary
agent.max_turnsapi_callsaccounting across auto-continue cyclesMotivation
Long autonomous workflows were stopping at the iteration/tool-turn ceiling only to require the user to say "continue". This patch lets Hermes continue boundedly when configured, while preserving the existing fallback summary path once the auto-continue cap is reached.
Validation
pytest tests/run_agent/test_run_agent.py tests/cli/test_cli_retry.py tests/gateway/test_retry_replacement.py tests/tui_gateway/test_protocol.py -k "auto_continue or retry" -qpytest tests/run_agent/test_run_agent.py::TestHandleMaxIterations::test_auto_continue_helper_injects_prompt_and_resets_budget tests/run_agent/test_run_agent.py::TestRunConversation::test_auto_continue_on_iteration_exhaustion_resumes_without_summary -qpython -m py_compile agent/chat_completion_helpers.py agent/conversation_loop.py cli.py gateway/run.py tui_gateway/server.py hermes_cli/config.py run_agent.pyIndependent review
api_callsaccounting regression are fixed