Skip to content

ux(mcp): over-bound tool documents silently drop structuredContent although every tool advertises an outputSchema #7768

Closed

Description

@EffortlessSteven

Symptom

For every tool except ripr_list_gaps, a success document whose double-carry envelope exceeds the 128-KiB response bound ships as content[0].text only — structuredContent is silently dropped, with no in-band signal that it is absent — even though each of these tools advertises an outputSchema, which per the MCP contract is what structuredContent is for. Only the tool descriptions' own text hints nothing about this conditional absence.

Evidence

Read-only audit at 243a8548b (origin/main).

  • crates/ripr/src/mcp/protocol.rs:266-289 — tool_result builds {content, structuredContent, isError: false}; when it measures over MAX_RESPONSE_BYTES it falls back to a text-only envelope {content, isError: false} and returns it without any marker (comment at :256-265 states this is by design).
  • crates/ripr/src/mcp/workspace.rs:555-557,601-616 — ripr_list_gaps is the only tool that pins "a tool that advertises an outputSchema always returns a structured result" and fails closed with result_too_large when even one summary cannot fit the structured envelope.
  • All other tools (ripr_workspace_status, ripr_refresh, ripr_get_gap, ripr_prepare_repair, ripr_get_repair_attempt, ripr_get_receipt_status, ripr_get_repair_card) route through bounded_tool_result → tool_result, so their large documents lose structuredContent silently.

Probe: a ripr_refresh on a scratch repository returned a success envelope whose structuredContent was present (small document); the code path above is taken only past the bound, which no small fixture reaches — the drop is exercised in-crate (e.g. the #6021 envelope tests) rather than observable on a tiny repo.

Description check: GET_GAP_TOOL_DESCRIPTION (crates/ripr/src/mcp/protocol.rs:72) promises "one canonical item's complete bounded evidence" and names result_too_large for over-bound items, but says nothing about structuredContent being absent for items that fit as text yet not as double-carry; same for the repair-attempt / receipt / repair-card descriptions. Only the repo's own docs disclose it: docs/interop/mcp.md:163-166 — "structuredContent repeats it only while the complete envelope stays under the response bound."

Why it frustrates

An agent (or host framework) that consumes structuredContent as the schema-bearing representation — the MCP-recommended way to consume tools that advertise outputSchema — parses a large-but-legal gap or repair-attempt document and finds the field missing with no error and no explanation. Reasonable but wrong inferences: the server is buggy, the document was truncated, or the tool contract changed. The agent then either re-calls the same tool (same outcome), falls back to regex-parsing content[0].text (works, but silently abandons the schema contract), or discards the evidence. The failure mode is indistinguishable from success unless the client defensively checks for structuredContent on every call — exactly the kind of undocumented edge that costs an agent several wasted turns on a large repository, where it is most likely to trigger.

Suggested direction

Cheapest honest fix: state the conditional absence in each affected tool description (one clause: "when the document fits the response bound only as compact text, structuredContent is omitted; parse content[0].text as JSON"). Stronger: carry a small marker (e.g. structuredContent: null plus a limitations entry, or a typed structured_content_omitted flag) so the omission is machine-detectable, mirroring how result_too_large is typed rather than implied.

Classification

verified_current — code path and description gap confirmed against HEAD source (243a8548b); live trigger requires a document near the 128-KiB bound. Confidence: medium (impact depends on whether the consuming host reads structuredContent preferentially).

Activity

  1. EffortlessSteven commented on Oct 15, 2026

    @EffortlessSteven
    MemberAuthor

    Bounded implementation continuation: Draft PR #8043 (#8043) now owns the empty ripr_list_gaps structured-envelope repair. Published head 383f2ece7088f1b59447ed2f2594bcdf82709785 preserves exact executed/reviewed tree 3b3e722650c4419a88a0ab4ad8b6fd6c7b7530cb; original head 856a26111d41ed489815eb461459f74b58219908 and tests-first 6ec976646cc71b9a844dd47f8bff44e1da707874 map to new remote commit envelopes in the PR body. All six blobs/modes and both complete trees were verified. The existing source task remains the retained evidence owner; no parallel implementation was created.

    The same real-stdio regression was RED on the original test-only tree and GREEN unchanged after repair. SDK 4/4, stdio 18/18, selected workspace 24/24, workspace/all-target Clippy and direct policy/contract checks passed on the original exact source. Full independent review and proof identities are retained in #8043 (comment).

    Independent published-head source/oracle review binding is complete with no new scoped blocker: #8043 (review). Keep Draft: genuine-base check-fast/precommit selectors and required hosted/integration qualification remain NOT_PROVEN. No Ready transition, Cargo rerun, release or merge occurred in publication. Parent owns those next judgments. This slice checks empty pages with the existing tool-envelope authority and typed refusal, preserving schemas, nonempty paging and recovery; it does not close #7768. Other tool cases and the independently reproduced inherited outer JSON-RPC/request-ID budget edge remain open.

  2. EffortlessSteven commented on Oct 15, 2026

    @EffortlessSteven
    MemberAuthor

    Outer JSON-RPC/request-ID budget slice landed: PR #8103 squash-merged as bb4295e97dbea37145c6b8832e93cfc9d3a13f54 (verified on main via ls-remote; PR state MERGED at 2026-10-15T09:31:51Z; required Ripr Rust Small Result success on head 0133287ef). Part of #7768 — the issue stays open for its remaining acceptance item.

    What landed. Every MCP tool and resource producer now measures against one id-aware response budget — MAX_RESPONSE_BYTES minus the JSON-serialized request id of the call being answered minus a fixed OUTER_RESPONSE_OVERHEAD_BYTES = 128 reserve for the JSON-RPC frame fields and the modern resultType field — threaded through tool_result, structured_envelope_overflows (list-gaps structured fit and bisect), bounded_tool_envelope, resource_result, and the newly measured status-resource read (crates/ripr/src/mcp/mod.rs, protocol.rs, server.rs, workspace.rs). ripr_list_repair_attempts keeps its existing id-aware ceiling, now fed from the shared helper. An envelope that passes the budget provably fits the writer cap whatever id the client sent; oversized results return the typed result_too_large refusal with recovery instead of the correlated generic -32603 fallback. The writer backstop and the MCP output limit termination remain the documented last resort for ids so large that even the typed refusal cannot fit; docs/interop/mcp.md and RIPR-SPEC-0211 now describe the reservation (the previous "fails closed ... before the wire cap" claim was false for large ids).

    RED witness. The retained stdio regression long_request_ids_refuse_typed_before_the_wire_cap drove a legal escaping-heavy request id sized from envelopes measured on the live wire: on the pre-fix tree the call answered the correlated -32603 MCP response exceeds the configured byte limit (native test failure, no result, no typed refusal); after the repair the same call returns the typed result_too_large refusal with the snapshot-bound recovery, a fit id one notch lower still ships a structured page, and the resource-read arm covers the same refusal/fit pair for ripr://workspace/status. Mutation check: disabling the id-aware reservation fails the stdio regression and the server boundary test; restored, both pass.

    Boundary coverage. Exact budget-1/budget/budget+1 flips (tool_result_fits_and_refuses_at_the_id_aware_envelope_budget); quote/backslash/control/non-ASCII escaping multipliers charged exactly against the real encoder (request_id_escaping_is_charged_exactly_by_the_outer_budget, outer_envelope_budget_reserves_the_escaped_request_id); pinned rmcp 3.5.1 overhead measured at 33 payload bytes legacy / 57 modern, inside the 128 reserve for both negotiated shapes (pinned_sdk_wraps_the_measured_envelope_within_the_outer_reserve); id-aware pager refusal and bisection (list_gaps_honors_the_id_aware_envelope_budget); long-id typed refusal end-to-end through bounded_tool_result (long_request_id_refuses_typed_at_the_id_aware_boundary). Local proof on 0133287ef: fmt --check, clippy -p ripr --all-targets -D warnings, stdio 19/19 + SDK 4/4 + workspace-config 6/6 and lib mcp:: 156/156 (single-threaded; the parallel lib-suite flake is the recorded host issue, not fixed here), goldens check exit 0, and the policy cascade (no-panic, process, allow-attributes, static-language, executable-files, network, lint, traceability, covered-by, spec-format, spec-numbering, file-policy) all exit 0. Required hosted qualification ran on the published head: Routed Rust Small runs 38703368857 (f4f9e32) and 38707248517 (0133287), both success; all PR checks green at merge.

    Review. Six review threads on #8103, all addressed or refuted with replies and read back resolved=true: two fixed (the Debug-rendering oracle could not catch a text-only regression — now asserts the serialized wire shape; resource reads lacked wire-level coverage — added), two refuted as the pre-existing pinned #5254-item-4/#6291 status pattern (typed refusal after the wrapper adds recovery text; demotion remains the parent residual), two refuted as pre-existing measurement style (counting-writer refactor out of scope).

    Remaining acceptance item. The issue's original symptom — a document that fits only as compact text silently loses structuredContent on the non-listing tools (and on listing tools past the envelope budget) — remains the documented #6021/#7768 fallback behavior; that typed-marker-or-description residual is the next owner's claim. The writer backstop ladder (typed refusal → correlated fallback → MCP output limit termination) is unchanged and documented.

  3. EffortlessSteven commented on Oct 16, 2026

    @EffortlessSteven
    MemberAuthor

    Final slice landed: PR #8167 squash-merged as 97cc171257fd76a1b3b9e79cc41ad949e0ecc861 (verified on main via ls-remote; PR state MERGED at 2026-10-16T03:56:58Z). This claimed the remaining acceptance item recorded in the #8103 reconciliation (comment 6189000150) — the issue's ORIGINAL symptom — so with #8043 (empty pages) and #8103 (outer id-aware budget) the acceptance set is complete and the issue closes.

    What landed. The text-only success fallback in protocol::tool_result is removed. A success document whose complete double-carry envelope cannot fit the caller's id-aware response budget now fails closed with the typed result_too_large refusal naming both sizes, the budget, the bound, and the dropped field, and every caller maps it to its per-tool recovery route — the same answer the two pagers already give past their paging envelope budget. Every tool that advertises an outputSchema now either ships structuredContent or refuses typed; silent absence is no longer a representable wire state.

    Why removal, not a marker or a description clause. The reachability re-read on current main found the fallback live on every non-paging tool: ripr_workspace_status/ripr_refresh had no structured pre-check at all, and the single-item tools' bounded_document guard sits at the raw 128-KiB cap while tool_result measures the ~2× double-carry envelope — a silent window at roughly (65.5 KiB, 131 KiB] of document bytes. A marker would have kept the degraded response; a description clause would have documented the loss. Removal makes code, spec (RIPR-SPEC-0211), docs/interop/mcp.md and docs/OUTPUT_SCHEMA.md state one contract.

    Evidence. RED on the pre-fix tree (20022bbfe) at five discriminating sites — the flipped #6021 double-envelope unit arms, a structured-overflow/compact-fits window arm in the server long-id boundary test, a new window-sized ripr_get_gap dispatch test asserting the serialized wire shape, and a new raw-stdio regression whose legal escaping-heavy request id is sized from the measured ripr_workspace_status envelope so the id-aware budget sits inside the refusal window (fit control one notch below). GREEN after: lib mcp:: 157/157 (single-threaded), stdio 20/20, SDK 4/4, goldens check pass, fmt/clippy/policy cascade exit 0. Local full proof and review-thread resolution (one Devin thread: changelog entry moved to changelog.d/8167-mcp-envelope-refuses-typed.md per policy, resolved with reply, read back resolved=true) are recorded on the PR.

    Routed separately (not this issue's scope). Hosted cargo-deny is red repo-wide since ~03:32Z: crates.io yanked the entire zip 8.x line while Cargo.lock pins 8.6.0 and deny.toml sets yanked = "deny"; xtask's zip = "^8" has no non-yanked 8.x (cargo update -p zip --dry-run lists 8.0.0–8.6.0 all yanked). It passed on this PR's first head and the branch's lockfile is byte-identical to main's — an inherited dependency decision (major bump, un-yank, or policy exception) for the owner, documented in the PR body.

    Non-claims: no analyzer classification change, no pager or writer-backstop change, no release/package qualification.

  4. EffortlessSteven commented on Oct 16, 2026

    @EffortlessSteven
    MemberAuthor

    Closing: the original symptom — the silent text-only drop of structuredContent on every non-paging tool — is repaired by #8167 (merge 97cc171), the last open acceptance item after #8043 and #8103. Reconciliation in comment 6207745567.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions