fix(agent): honor AgentToolResult.terminate#432
Open
d8rt8v wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Updates Tau’s provider/tool agent loop to respect AgentToolResult.terminate, aligning early-termination behavior with Pi and preventing unnecessary follow-up model turns (especially under tight max_turns limits).
Changes:
- Collects finalized tool execution results (
ToolExecutionEndEvent.result) across the full tool-call batch. - Skips the automatic follow-up model turn only when all tool results explicitly request termination (
terminate is True), while mixed batches continue normally.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+160
to
+162
| has_more_tools = bool(final_tool_results) and not all( | ||
| result.terminate is True for result in final_tool_results | ||
| ) |
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
Honor
AgentToolResult.terminatein the agent loop.The loop now collects finalized results after the complete tool-call batch has run and skips the automatic follow-up model turn only when every result requests termination. Results modified by
after_tool_callare respected, while mixed batches continue normally.Reproduction
Before this change, a custom terminal tool could return:
The tool completed successfully, but the loop set
has_more_toolsfrom the presence of tool calls alone and made another provider request. Withmax_turns=1, the attempted follow-up also turned a successful run intoAgent stopped after max_turns=1.This is the same early-termination behavior fixed in Pi:
Validation
uv run pytestuv run ruff check .uv run ruff format --check .uv run mypy