Skip to content

fix(acp): preserve JSON-RPC error data - #2436

Open
brainx wants to merge 5 commits into
block:mainfrom
brainx:agent/preserve-acp-error-data
Open

fix(acp): preserve JSON-RPC error data#2436
brainx wants to merge 5 commits into
block:mainfrom
brainx:agent/preserve-acp-error-data

Conversation

@brainx

@brainx brainx commented Jul 22, 2026

Copy link
Copy Markdown

Problem

buzz-acp currently keeps only a JSON-RPC error's code and message. Adapter diagnostics carried in error.data are lost, turning actionable failures such as an incompatible CLI flag into a generic -32603 Internal error.

Fix

Preserve error.data as a compact, UTF-8-safe, 4 KiB-bounded owner diagnostic. High-level logs and channel failure notices continue to use only the public code and message; the encrypted turn_error observer payload receives the detail in a separate data field.

Errors without a string message retain their bounded full error object for owner diagnosis. The implementation retains immediate handling for non-retryable authentication failures.

Regression guard

Add focused tests for structured data, missing and null messages, UTF-8 truncation, public display behavior, observer propagation, and owner-transcript rendering.

Testing

  • cargo fmt --all -- --check — passed
  • cargo test -p buzz-acp — 621 unit tests and 9 lifecycle tests passed
  • node --import ./test-loader.mjs --experimental-strip-types --test src/features/agents/ui/agentSessionTranscript.test.mjs — 51 passed
  • pnpm exec biome check src/features/agents/lib/friendlyAgentLastError.ts src/features/agents/ui/agentSessionTranscript.ts src/features/agents/ui/agentSessionTranscript.test.mjs — passed
  • git diff --check upstream/main...HEAD — passed

Addresses the diagnostic-loss portion of #2422.

Signed-off-by: brainx <12695242+brainx@users.noreply.github.com>
@brainx
brainx marked this pull request as ready for review July 23, 2026 00:03
@brainx
brainx requested a review from a team as a code owner July 23, 2026 00:04

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 701ec6b5a3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/buzz-acp/src/acp.rs
@SeanGearin

Copy link
Copy Markdown
Contributor

Solid root-cause fix — preserving data structurally is clearly right for tooling that wants to parse it. One thing worth flagging on the desktop consumer side, since it affects whether operators actually see the detail you're now preserving: the transcript builds its user-facing text from payload.error / payload.code (agentSessionTranscript.ts:775-776) and never reads payload.data, and friendlyAgentLastError's -32603 branch (written to preserve adapter detail after the standard prefix) never receives any, because buzz-acp strips it upstream. So today the detail lands in the observer payload but not in front of the operator.

Relatedly, the codex reviewer's P2 on the "Unknown agent error" message-missing fallback looks real: for data-only errors that string becomes all a string-based consumer gets, where error.to_string() previously at least carried the raw JSON. If you also appended the bounded data onto the AgentError message itself (in addition to the structured field), the existing Display/to_string() surfaces — harness logs, the channel retry notice, and that -32603 preserve-detail branch — would light up with no new plumbing, and the fallback wouldn't drop detail. Structured field for tooling + message append for humans compose cleanly. Happy to help with the message-side piece if useful.

Signed-off-by: brainx <12695242+brainx@users.noreply.github.com>

brainx commented Jul 23, 2026

Copy link
Copy Markdown
Author

@SeanGearin Addressed in d835077c by consuming the bounded turn_error.data field in the desktop owner transcript. I kept it out of AcpError::Display because that text also feeds general logs and channel retry notices. This keeps the diagnostic human-visible to the operator without broadening its exposure. Regression coverage includes both data-only and -32603 errors.

Signed-off-by: brainx <12695242+brainx@users.noreply.github.com>
@brainx

brainx commented Jul 26, 2026

Copy link
Copy Markdown
Author

Updated the branch to current main in f7ef14d3. The conflict resolution preserves both the bounded owner-only error.data diagnostics and the newer immediate handling for non-retryable authentication errors. Current-head verification passed: cargo test -p buzz-acp (603 unit + 9 lifecycle tests), the 51 transcript tests, Rust formatting, and targeted Biome checks. DCO is green; the refreshed CI and Docker workflow runs are awaiting maintainer approval.

Signed-off-by: brainx <12695242+brainx@users.noreply.github.com>
@SeanGearin

Copy link
Copy Markdown
Contributor

Verified d835077 against the head - friendlyTurnErrorCopy consuming payload.data with the transcript-only scoping is exactly the shape I was hoping for, and pinning both the data-only -32000 and -32603 cases means the visibility can't silently regress. Keeping it out of Display was the right call for the log/notice surfaces. Nothing further from me - this looks ready for a maintainer pass.

…error-data

Signed-off-by: brainx <12695242+brainx@users.noreply.github.com>
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.

2 participants