Repository navigation
fix: settle approved tool calls that never ran (#2382) - #2392
Merged
threepointone merged 1 commit intoSep 28, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: a2287c6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
threepointone
added this pull request to stack #2395
September 28, 2026 10:50
Contributor
|
✅ agents import sizes: no significant changes ( |
threepointone
force-pushed
the
fix/2382-approved-tool-repair
branch
from
September 28, 2026 10:57
d9af377 to
7443ec5
Compare
threepointone
marked this pull request as ready for review
September 28, 2026 10:57
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
threepointone
force-pushed
the
fix/2382-approved-tool-repair
branch
from
September 28, 2026 11:36
7443ec5 to
75273c9
Compare
…2382) Co-authored-by: Cursor <cursoragent@cursor.com>
threepointone
force-pushed
the
fix/2382-approved-tool-repair
branch
from
September 28, 2026 11:58
75273c9 to
a2287c6
Compare
Merged
tombeckenham
added a commit
to tombeckenham/agents-tom
that referenced
this pull request
Oct 7, 2026
…gine Ports four upstream changes to the legacy AIChatAgent onto AGUIChatAgent: - cloudflare#2352: clear a stale auto-continuation when the active stream finishes with stop and the tool batch is complete (finishReason read from RUN_FINISHED via the accumulator). - cloudflare#2391: a tool call whose arguments complete after its approval request refreshes the persisted approval snapshot; the event-to-chunk projection re-sends the approval request after the late tool-input-available. - cloudflare#2392: settle an approved tool call that never ran once a new turn moves past it. The pre-turn repair now also runs on submitted turns. - cloudflare#2040: reconcile reused tool-call IDs one-to-one in the AG-UI reconciler (same-call claim, per-row result merge, stale-copy drop). Test plumbing: the legacy-wire WebSocket wrapper translated each frame once per listener through a stateful projector, so a second listener lost chunks. It now translates once per frame.
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.
Fixes #2382. Stacked on #2391.
Problem
Approving a tool with
autoContinue: falseand never resubmitting leaves anapproval-respondedpart in the transcript for good. OpenAI-compatible providers then reject every later request, because the tool call has no result. The conversation is stuck.Change
repairInterruptedToolPartsgets arepairApprovalRespondedoption. With it on, anapproval-respondedpart that is not in the last message is settled:output-errorwith "The tool call was approved but did not run before the next turn started."output-deniedAn approval in the last message is always kept. That covers the
autoContinue: falseresubmit flow, where the AI SDK runs the approved tool itself.Think and AIChatAgent turn the option on only for new user and programmatic turns. It stays off for continuations, while a continuation is pending or deferred, and (in Think) while a connection-less continuation is queued. That way an approval that is about to run is never settled early.
Tests
repair-transcript.test.ts: 5 tests for approved, denied, last-message and option-off cases.ai-chatstale-approval-repair.test.ts: 2 tests.client-tools.test.ts: an approved tool that never ran is settled once the user sends a new message, and the tool never executes.