fix(acp): surface JSON-RPC error data.details to users#895
Closed
howie wants to merge 1 commit into
Closed
Conversation
`JsonRpcError` previously deserialized only `code` and `message`, silently dropping the optional `data` field defined in JSON-RPC 2.0 §5.1. ACP adapters such as codex-acp put actionable detail strings in `data.details` (model id, auth hint, peer-dep failure, etc.), so every -32603 reaches users as the same opaque "Internal Error" regardless of cause. This change: - adds `data: Option<Value>` to `JsonRpcError` with a `data_details()` accessor mirroring the codex-acp / acpx convention, - threads the full error through `format_coded_error`, appending `data.details` when present and not already echoed in `message`, - updates the synthetic "connection closed" error in connection.rs and the call site in adapter.rs accordingly. Backward compatible: errors emitted by agents that don't set `data` deserialize unchanged (`#[serde(default)]`), and existing display formatting is preserved when `data.details` is absent.
|
All PRs must reference a prior Discord discussion to ensure community alignment before implementation. Please edit the PR description to include a link like: This PR will be automatically closed in 3 days if the link is not added. |
Collaborator
|
Closing as duplicate of #885 which was merged yesterday and addresses the same issue (extracting error.data from JSON-RPC errors). |
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.
What problem does this solve?
When an ACP agent emits a JSON-RPC error such as
{code: -32603, message: "Internal error"}, openab surfaces it as a single opaque "Internal Error (code: -32603)" — regardless of whether the actual cause is a deprecated model, an expired auth token, a missing npm peer dependency, or something else entirely.The reason is that
JsonRpcErrordeserializes onlycodeandmessage, silently dropping the optionaldatafield defined in JSON-RPC 2.0 §5.1. codex-acp (and other ACP adapters) put the actionable detail string indata.details, but openab discards it on the wire — so users see the same message for every cause and have no signal to recover.Related: #547 documents one specific multi-org Codex case where this surfaces. That issue proposes a docs-only fix; this PR addresses the underlying transparency gap so all -32603 sources (model deprecation, peer-dep failures, auth, multi-org, etc.) automatically surface their upstream detail.
At a Glance
Prior Art & Industry Research
OpenClaw — openclaw/acpx treats
data.detailsas a first-class field. acpx normalizes ACP errors through dedicated modules (error-shapes.ts,error-normalization.ts,session-control-errors.ts) that:data: unknownon every payload and walk it for typed hints (auth required, session not found, query closed).-32603viaacp.data.detailsstring matching.formatSessionControlAcpSummaryreadsdata?.detailsand renders${details} (ACP ${code}, adapter reported "${message}")).Hermes Agent — NousResearch/hermes-agent is the agent side and emits errors through the upstream
acpPython SDK (acp_adapter/server.py). The SDK preservesdataend-to-end, so client implementations that read it (acpx) see the agent's diagnostic context. The lesson: ACP's wire format already supports this — clients only need to deserialize the field.JSON-RPC 2.0 spec — §5.1 defines
dataas an optional member that "MAY be omitted" but "SHOULD" carry "additional information about the error" when present. Dropping it is a conformance gap.Proposed Solution
Minimal, surgical change in four files:
src/acp/protocol.rs— Adddata: Option<serde_json::Value>toJsonRpcError(with#[serde(default)]for back-compat), plus adata_details()accessor that mirrors the codex-acp / acpx convention (data.detailsas a string).src/error_display.rs— Changeformat_coded_errorto take&JsonRpcError, appenddata.detailswhen present, and de-duplicate whenmessagealready contains the same text (some adapters echodetailsintomessagefor legacy clients).src/adapter.rs— Update the single call site at the response-error handler.src/acp/connection.rs— Adddata: Noneto the synthetic "connection closed" error.Tests cover: deserialize round-trip with and without
data, non-stringdetails(ignored), unknown data shapes (ignored), empty/whitespacedetails, and the de-duplication path. Existingformat_coded_errortests are migrated to the new signature.Why this approach?
#[serde(default)]means agents that don't emitdatadeserialize unchanged.Displayimpl preserves existing output whendata.detailsis absent.data.detailsstring convention exactly, so future cross-tool diagnostics stay consistent.Known limitations:
data.details(string) is surfaced. acpx additionally recognisesdata.authRequired,data.methodId,data.methodsfor richer auth flows — out of scope here, can be added incrementally without breaking this change.dataas JSON whendetailsis missing or non-string (silently ignored). This is conservative — avoids leaking implementation-defined payloads.Alternatives Considered
error-normalization,error-shapes,NormalizedOutputError, retryable classification). Rejected: acpx is a CLI that exits with structured codes — openab is a chat adapter that streams text. The full taxonomy is value for CLI consumers but overhead here, and bundles unrelated concerns (retry policy, exit codes) into one PR.data.detailsintomessage. Rejected: the wire format already supportsdata; the bug is openab dropping it. Fixing it client-side keeps the change in one repo and benefits every ACP adapter, not just codex-acp.dataas JSON in user output. Rejected: leaks implementation detail and risks confusing users with adapter-internal fields.data.detailsis the documented convention.Validation
cargo check— cleancargo test— 373 passed, 0 failed. 11 new tests cover:acp::protocol: deserialize with/withoutdata, non-string details,Displayimplerror_display: append details, message-only fallback, dedup, unknown shapes, whitespacecargo clippy --all-targetson the changed files — clean. (2 pre-existing warnings insrc/cron.rsexist onorigin/mainand are unrelated to this PR.)Manual: not deployed to a live agent (would need a codex-acp instance hitting a known error); the format paths are exercised end-to-end by the new tests including the model-deprecation scenario from CLAUDE.md gotchas.