Repository navigation
Improve tool call and session cancellation reliability - #769
Merged
alejandro-ao merged 3 commits intoOct 23, 2026
Merged
Conversation
added 2 commits
October 13, 2026 09:04
When a run was cancelled during tool execution (the user cancelling a
running command, or a before_tool_call hook stopping the run), the loop
still started the next provider request. That request saw the cancel
mid-read and returned without a terminal event, so the run ended as an
error ("Provider stream ended without a terminal event") instead of as
aborted.
The loop now checks the signal before each request and ends the run with
stop_reason "aborted". If the tool call that cancelled the run returned
an error, its text becomes error_message, so a hook's reason is kept;
otherwise it is "Operation aborted".
…string"
Providers pass a tool call whose argument text is not valid JSON as
{"_raw_arguments": text}, usually a reply cut off at the output limit
(e.g. a write of a large file). The tool found no path and answered
"path must be a string", and models tend to resend the same oversized
call. Such a call now fails with an error that names the cut-off and
suggests sending less per call.
A call that omits a required string argument got the same error. It now
names the missing argument and the ones that were sent. A present value
of the wrong type still gets "must be a string".
alejandro-ao
approved these changes
Oct 23, 2026
alejandro-ao
left a comment
Collaborator
There was a problem hiding this comment.
Approved after review and re-validation at merged head 0d2ec160 (PR head + latest main):
- Full test suite: 2098 passed, 2 skipped
ruff check/ruff format --check: cleanmypy(strict): clean- Required CI checks on updated head:
Python checksandDocumentation buildboth pass
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.
Analysis of traces showed that models would often fail to recover from bad tool calls, in part because the error response from tau did not provide a clear reason for the failure (just "path must be a string"). This disproportionately affects smaller models. The main change in this PR is to provide a diagnostic about missing arguments, the most common failure that is also correctible with feedback. As a follow-on, during tool calls I noticed that session cancellation doesn't always work. Rather than spam ctrl-c, with the second change in this PR once is enough. Subjectively this makes tau usage more reliable but I do not have a quantitative comparison of the before/after.
All tests pass and these changes have been tested in many sessions.