fix: tool approval deny flow breaks subsequent messages#1493
Open
sAkuraOfficial wants to merge 2 commits into
Open
fix: tool approval deny flow breaks subsequent messages#1493sAkuraOfficial wants to merge 2 commits into
sAkuraOfficial wants to merge 2 commits into
Conversation
Contributor
|
@sAkuraOfficial is attempting to deploy a commit to the Templates Test vtest314 Team on Vercel. A member of the Team first needs to authorize it. |
Author
da2e118 fix: error when continuing conversation without handling approvalbefore fix:before.fix.mp4after fix:after.fix.mp4 |
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.
fix: tool approval deny flow breaks subsequent messages
Fixes two related bugs in the tool approval flow that cause user messages to be silently dropped after denying a tool call.
When a user denies a tool approval (e.g., clicks "Deny" on ``), two issues occur:
The deny action never reaches the server —
sendAutomaticallyWhenonly triggers whenapproved === true, so denials are silently swallowed on the client.All subsequent user messages are lost — After a denial, any new message the user types is incorrectly treated as a tool approval continuation. The message is never sent to the model, never saved to the database, and disappears on page refresh.
before fix bug
error.example.mp4
After fix bug
success.example.mp4
Root Cause
Issue 1:
sendAutomaticallyWhenignores denialssendAutomaticallyWhen: ({ messages: currentMessages }) => { const lastMessage = currentMessages.at(-1); return ( lastMessage?.parts?.some( (part) => "state" in part && part.state === "approval-responded" && - "approval" in part && - (part.approval as { approved?: boolean })?.approved === true + "approval" in part ) ?? false ); },The
approved === truecheck means only approvals trigger auto-send. Denials update the local state toapproval-respondedbut never send a request to the server.Issue 2:
||inprepareSendMessagesRequestcorrupts subsequent requestsWith
||, the condition evaluates as:lastMessage?.role !== "user"→false(it IS a user message)request.messages.some(...)→true(history containsapproval-respondedfrom the earlier deny)false || true = true→ incorrectly enters approval modeThis causes the request body to send

{ messages: allMessages }instead of{ message: lastMessage }. The backend then enters the tool approval branch (Boolean(messages) = true), which only performs approval state merging and completely ignores the user's new message.Result: The user's message is never sent to the model, never persisted to the database, and the model only sees the old denial — responding with "user denied" repeatedly.
With
&&, a new user message (lastMessage.role === "user") always takes the normal path regardless of historical approval states, which is the correct behavior.Steps to Reproduce and video
decryptSkaKey)Changes
sendAutomaticallyWhen: Removeapproved === truefilter so denials also trigger a server requestprepareSendMessagesRequest: Change||to&&so new user messages are never misclassified as tool approval continuations