fix(chat): cancel tool call when user sends message without accepting/rejecting diff#12095
Open
octo-patch wants to merge 1 commit intocontinuedev:mainfrom
Open
Conversation
…/rejecting diff When multi_edit (or similar tools) presents a diff and the user sends a new message without clicking Accept or Reject, the tool call was left in calling state with no output. This caused constructMessages to emit No tool output, which made the model assume the edit succeeded and proceed with incorrect assumptions about file contents. Now, when pending apply states are rejected because the user sends a new message, we also cancel any associated tool calls. This changes the tool result from No tool output to the cancellation message, correctly signaling to the model that the edit was not applied. Fixes continuedev#12051
Contributor
|
I have read the CLA Document and I hereby sign the CLA octo-patch seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. |
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 #12051
Problem
When
multi_edit(or similar tools withrespondImmediately: false) presents a diff and the user sends a new message without clicking Accept or Reject, the tool call remains incallingstate with no output.constructMessagesemits"No tool output", making the model assume the edit succeeded. Subsequentmulti_editcalls then fail because theirold_stringvalues no longer match the actual (unmodified) file.Solution
When pending apply states (status
"done") are rejected because the user sends a new message, we now also dispatchcancelToolCallfor any associated tool call IDs. The tool call transitions fromcallingtocanceledstatus before messages are constructed and sent to the model.The model now receives
"The user cancelled this tool call."instead of"No tool output", correctly signaling that the edit was not applied.Testing
multi_edit"No tool output"and proceeds as if edit succeededSummary by cubic
Cancel
multi_edit(and otherrespondImmediately: falsetools) when the user sends a new chat message without accepting/rejecting the diff. The tool call now moves tocanceled, and the model sees a clear cancellation instead of "No tool output."cancelToolCallwhen rejecting pending apply states on new message.multi_editfailures from mismatchedold_stringvalues.Written for commit 25bd83d. Summary will update on new commits.