fix(agent): synthesize results after terminal loop caps - #76080
fix(agent): synthesize results after terminal loop caps#76080seppegadeyne wants to merge 1 commit into
Conversation
Related: #64363 proposes a broader tool-enabled rebound after hard stops, while this PR limits terminal caps to one tool-free final synthesis. Maintainers should choose the intended recovery contract. |
|
Thank you for the focused cap-handling work and the provider-specific tests.
This is an automated hermes-sweeper review. Closed as not-planned per standing maintainer policy ( |
|
Acknowledged. This proposal intentionally used a tool-free terminal synthesis, so the |
What does this PR do?
Terminal
loop_web_search_capandloop_subagent_capguardrails currently replace all collected work with a canned stop message. This PR preserves the cap while asking the current model for one tool-free final response from the evidence already in the turn.It also makes terminal-cap handling fail-closed within a mixed tool batch: when the next emitted batch would cross one of these caps, calls are reserved in order and every call after the capped search/delegation is closed with a synthetic skipped result instead of being allowed to start concurrently.
The summary path:
result["api_calls"]Other hard-stop guardrails retain their current behavior. This is intentionally narrower than a general “one rebound” implementation.
Related Issue(s)
Related to #64322.
Complements, but does not supersede, the broader recovery proposal in #64363. This PR handles only the terminal per-turn caps added in #66600; it does not give other hard-stop guardrails another tool-enabled model round.
Testing
scripts/run_tests.sh tests/run_agent/test_tool_call_guardrail_runtime.py tests/agent/test_tool_guardrails.py tests/run_agent/test_agent_guardrails.py tests/run_agent/test_run_agent.py tests/run_agent/test_tool_batch_segmentation.py tests/run_agent/test_tool_call_incremental_persistence.py tests/run_agent/test_concurrent_interrupt.py tests/run_agent/test_tool_executor_contextvar_propagation.py -q.venv/bin/ruff check ..venv/bin/python scripts/check-windows-footguns.py --allpython -m py_compilefor all changed Python filesgit diff --checkThe lone full-suite failure was
tests/agent/test_compression_concurrent_fork.py::test_fence_cancelled_compression_leaves_lock_reacquirable; this timing-sensitive compression file also fails in a cleanupstream/mainworktree with the same environment. Required GitHub CI remains authoritative for the complete matrix.Type of change
Checklist
./scripts/run_tests.shThe full-suite checkbox is intentionally left unchecked only because the clean-base failure documented above reproduces unchanged on
upstream/main; the focused 314-test regression set is green.Platform
Screenshots / Logs
Not applicable — agent runtime/control-flow change.
Additional Notes
Brave Search PR #75333 is unrelated: it changes setup-time capability detection only. The exact cap code is produced by #66600, while #31448 made controlled halt text visible to clients. This PR keeps both protections and changes only the terminal-cap recovery path.