Skip to content

feat(tool-call-mapping): emit compact file-edit diffs and raw io#283

Open
duclvz wants to merge 1 commit into
agentclientprotocol:mainfrom
duclvz:feat/structured-file-edit-reporting
Open

feat(tool-call-mapping): emit compact file-edit diffs and raw io#283
duclvz wants to merge 1 commit into
agentclientprotocol:mainfrom
duclvz:feat/structured-file-edit-reporting

Conversation

@duclvz

@duclvz duclvz commented Jul 10, 2026

Copy link
Copy Markdown

Summary

Replaces whole-file diff expansion in Codex file-change tool calls with the compact
per-hunk representation Codex actually sends, and populates the ACP tool_call
metadata fields that were previously left empty. This brings the adapter closer to
the ACP v1 tool-call contract and matches the behavior of other ACP adapters (e.g.
Claude Agent ACP).

What changed

  • Hunk-local diff contentcreateUpdateFileContent now parses the unified
    patch and emits one diff content block per hunk with localized oldText and
    newText, instead of reading the source file and expanding to whole-file
    contents. Also drops the disk read entirely, so edits still render correctly
    when the source file is unavailable or already patched.
  • locations — every file-change tool call now includes affected paths (and
    the first-hunk line number for updates / rename source + destination for moves).
  • rawInput / rawOutput — the tool call carries the normalized
    FileUpdateChange[] as rawInput, and terminal updates carry
    { status, success } as rawOutput.
  • item/fileChange/patchUpdated — previously ignored; now mapped to a
    tool_call_update carrying the refreshed hunks/locations while status stays
    in_progress.
  • Session history replay — still emits a single completed tool_call for each
    historical file change; the snapshot now includes the new fields.

Test plan

  • npm run typecheck
  • npm test (288 passing)
  • New regression coverage in file-change-events.test.ts:
    • invalid update patch → metadata preserved, content dropped
    • source file unavailable → still emits hunk-local diff
    • patchUpdated notification → compact content + metadata
    • start-before-completion ordering → no disk read on the in_progress emit

Notes

  • Behavior is additive: consumers that only read content[] still see valid diff
    entries, just scoped to hunks instead of whole files.
  • turn/diff/updated and item/fileChange/outputDelta remain intentionally
    ignored — the reproduced Codex 0.144 traffic did not emit them.

Replace whole-file diff expansion with hunk-local oldText/newText plus locations, normalized rawInput/rawOutput, and patchUpdated mapping for Codex file-change tool calls.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant