Skip to content

fix(acp): preserve JSON-RPC error.data when message is present (#4069) - #4084

Open
iroiro147 wants to merge 1 commit into
block:mainfrom
iroiro147:claude/issue4069-errordata-20260801
Open

fix(acp): preserve JSON-RPC error.data when message is present (#4069)#4084
iroiro147 wants to merge 1 commit into
block:mainfrom
iroiro147:claude/issue4069-errordata-20260801

Conversation

@iroiro147

Copy link
Copy Markdown

Summary

Fixes #4069 (partial — covers the cross-platform observability defect; the Windows ARM64 Node provisioning half is left to a follow-up).

agent_error_from_json in crates/buzz-acp/src/acp.rs was discarding the JSON-RPC error.data payload whenever the agent returned a string message. The ACP TypeScript SDK wraps plain thrown exceptions as:

{"code": -32603, "message": "Internal error", "data": {"details": "<fully actionable adapter message>"}}

so the actionable adapter text never reached Buzz logs — operators saw only Agent reported error (code -32603): Internal error.

What changed

When message is a string and a non-null data field is present, append a compact form of data to the surfaced message:

  • Prefer a nested data.details string when present (matches the ACP TS SDK's wrap shape).
  • Otherwise fall back to the data value stringified (handles plain string and structured data cases).
  • Truncate defensively at 2048 chars so a pathological adapter cannot flood logs.
  • data: null is ignored (no information).
  • Errors without a string message still fall back to the full JSON object as before — no behavior change there.

Test plan

Five new unit tests in crates/buzz-acp/src/acp.rs::tests:

Verification:

cargo check -p buzz-acp          # clean
cargo clippy -p buzz-acp --all-targets -- -D warnings   # clean
cargo test -p buzz-acp --lib     # 665 passed, 0 failed
cargo test -p buzz-acp agent_error_from_json   # 6 passed

Notes

The Windows ARM64 side of #4069 (Buzz provisioning win-x64 Node on an ARM64 host because managed_node_paths.rs reads std::env::consts::ARCH at compile time) is not addressed here — that's a runtime detection change requiring IsWow64Process2 / PROCESSOR_ARCHITEW6432 and would benefit from maintainer input on supported host matrix. This PR ships just the cross-platform logging fix so the next adapter failure of this shape surfaces its own remedy in the log.

Closes #4069

…#4069)

`agent_error_from_json` previously discarded the `data` payload
whenever the agent returned a string `message`. The ACP TypeScript
SDK wraps plain thrown exceptions as
`{code, message: "Internal error", data: {details: "<real cause>"}}`,
which hid actionable adapter remediation hints and made failures look
like opaque agent bugs (macOS/Windows ARM64 win-x64 vs win-arm64
misprovision, missing optional native SDK, etc.).

Append the data payload to the surfaced message, preferring a nested
`details` string when present and truncating oversized data defensively
at 2048 chars to keep logs readable. `data: null` is ignored; errors
without a string `message` still fall back to the full JSON as before.

Adds unit tests covering the new append path (nested `details`, plain
string `data`, null suppression, truncation) plus the original
message-only behavior.

Signed-off-by: iroiro147 <sarthak.singh@juspay.in>
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.

Windows on ARM64: Claude managed agents fail every session/new with -32603 (win-x64 Node provisioned on ARM64 host; error.data dropped from logs)

1 participant