Repository navigation
mcpx: typed sampling errors — -1 on rejection, expiry stays -32603 (#1835) - #2440
Conversation
…1835) Phase 1 of #1834. Adds mcpclient.CodedError (exported, errors.As-recognised) with UserRejectedError (-1), ToolShapeError (-32602, for Phase 2 #1836) and InternalError (-32603) constructors next to rpcError. sampleViaBroker returns typed -1 naming the action for a real decline/cancel and typed -32603 naming expiry for the broker-synthesized expiry answer (By==expiry checked first). Client.answer relays a typed handler code instead of flattening to -32603; untyped errors keep the -32603 wrap. Tests cover both Client.answer caller paths (legacy wire + modern input_required), the broker decline/cancel/expiry split, and a conformance row for the -1 half; the conformance gap is reworded to the -32602 content half only (#1836) and the matrix regenerated.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 18 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
🤖 Agent note · parked
|
Fixes #1835 — Phase 1 of #1834 (typed sampling errors), per triage task 2718. Queue task 3050.
What changed
internal/mcpclient— new exportedCodedErrortype (recognised viaerrors.As) with constructorsUserRejectedError(-1),ToolShapeError(-32602, defined for Phase 2 mcpx: Phase 2 of #1834 — sampling message + result validation at the broker (pairing, era shape, no silent fill-in) #1836 to raise; no content checks here), andInternalError(-32603);codeUserRejected = -1sits next tocodeInvalidParams. The existingrpcErrorplumbing from mcpx: design — sub-capability gating (gate on sampling.tools / sampling.context / elicitation.form, not parent presence) #1753 Phase 2 is reused, not duplicated.internal/mcpclient/modern.go—Client.answershared branch: a typed handler error is relayed with its own code and message; untyped handler errors keep today's exact -32603 wrap. Elicitation behaviour unchanged (elicit answers carry decline/cancel as result shapes, not errors).internal/daemon/hooks.go—sampleViaBroker: the broker's synthesized expiry answer (By == "expiry", checked before the generic non-Accept branch) returns a typed -32603 naming expiry — expiry is not a rejection. A decline/cancel by an actual answerer returns a typed -1 naming the action. The brokerAwaitraw-error path is unchanged.Tests
mcpclient: typed passthrough through bothClient.answercaller paths (legacy wire request and moderninput_required), wrapped-error (%w) recognition, tool-shape -32602 passthrough, untyped stays -32603.daemon: decline → -1 naming decline; cancel → -1 naming cancel; synthesized expiry answer → -32603 naming expiry.conformance: new row forsampling-client-errors-user-rejected-and-tool-shapeasserting -1 (passes underMCPX_CONFORMANCE_RUN_GAPS=1); the gap is reworded to only the -32602 content half for Phase 2 (mcpx: Phase 2 of #1834 — sampling message + result validation at the broker (pairing, era shape, no silent fill-in) #1836), anddocs/spec/conformance-matrix.mdregenerated.Targeted tests pass on the laptop (
go test ./internal/mcpclient/ -run TestSamplingTypedErrors|TestSamplingDeclarations|TestModernSamplingShape,go test ./internal/daemon/ -run TestSampleViaBrokerTypedErrors, conformance row +TestMatrixafter regeneration). Full suite verification is CI's job on this PR.Need help on this PR? Tag
@codesmith-botwith what you need.