Repository navigation
fix(acp): report tool names and full-file diffs - #53360
Merged
Merged
Conversation
Completed tool diffs come from FileDiff metadata, reversed against the file already on disk. Patch tools still use their own hunks. The first tool_call carries the raw tool name.
Completed diffs apply the recorded FileDiff patch first. Patch tools rebuild from hunks only when that reverse fails and the hunk ranges still match.
2 of 6 tasks
3 of 6 tasks
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.
Part of #52636
Why the change
Completed tool calls built their ACP diff from the edit tool's
oldString/newStringsnippets, so clients that draw inline diffs from that content showed partial or wrong diffs for edits and nothing for the patch tool or plugin edit tools. After this change, diffs are built from the file changes core already reports, and the firsttool_callcarries the tool'sname, which the spec says agents SHOULD include.Special things to note
metadata.fileson success, unlike edit (core/src/tool/plugin/write.ts). Fixing that needs a small core change, so this PR leaves ACP: completed tool_call_update diff content is derived from tool input schema, not result metadata — write/patch and plugin edit tools never emit diffs #52636 open. Plugins that report diffs in another metadata shape also still get none.session/load, diffs are rebuilt against the file as it is now. If the file changed near an edit since then, reversing the patch fails and that call replays without a diff. If it changed elsewhere, the highlighted change is still exactly the tool's, but the unchanged lines around it come from today's file. Snippet diffs are gone, so edits migrated from V1, which store nofiles, replay without a diff.applyPatchcan't reverse them on indented code. For those files, the diff is rebuilt from the tool's own hunks and kept only if its@@ranges match the recorded patch. A completed patch-tool delete of a trimmed file gets no diff, because delete hunks have no body.Change outline
A completed update's diff now comes from core's
FileDiffmetadata, read against the file on disk. After a successful tool call, the disk holds the new text, so the old text is rebuilt by reversing the recorded patch.translate.foldstays pure. It attaches the source to the output forsession.tool.success, and the file read happens where updates are sent. Permission previews don't change.nameis the raw tool name, not the alias-mapped one. It goes on the firsttool_call, both live and on replay. A permission ask for a known tool repeats it. An ask without a known tool leaves it out, because a permission action such asexternal_directoryisn't a tool.pendingToolCall -> ToolCall toolCallId, title, kind, status: "pending", ... + name: toolNameTests build fixture diffs with
createTwoFilesPatch, as core does, through a sharedfileDiffhelper inwire-fixture.ts: