Skip to content

fix(mcp): record deferred schemas before protocol framing - #9351

Merged
kaoru0822-kitauji merged 2 commits into
mainfrom
codex/mcp-deferred-union-schemas
Nov 12, 2026
Merged

kaoru0822-kitauji merged 2 commits into
mainfrom
codex/mcp-deferred-union-schemas

Conversation

@kaoru0822-kitauji

@kaoru0822-kitauji kaoru0822-kitauji commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

A fresh default full-catalog connection advertises a legacy {result: ...} wrapper for search_guidance, but deferred materialization returns the canonical union object. The stock SDK rejects it before an agent can read guidance. This blocks the on-demand guidance work in #9347.

Record output projections before protocol framing. The SDK owns root wrapping for both listings and replies; deferred registrations retain canonical validation and the recorded schema. No target/provider behavior, authority or cleanup policy changes.

Validation

Runtime CI passed at 9304152a9; human author readiness remains pending.

Current head 9304152a9, Node 24.22.1 / npm 11.16.0 / macOS arm64:

  • 35 real stdio boundary tests pass. Four input-profile/protocol cases now compare every deferred tool definition with independently composed eager SDK registrations, before and after materialization. Other cases cover hot/cold loading, output-off, source analysis, identity, recorder isolation, late initialization, shutdown and cleanup retry.
  • 17 SDK boundary tests pass. New legacy/modern object-union cases execute malformed handler output and require a server-side validation error, rather than success or only a client-validator exception. They preserve schema equality through materialization. Existing cancellation, independent-peer, partial-startup and cleanup coverage remains.
  • npm run check:fast and touched formatting/diff checks pass.
  • The original two guidance regressions fail on pinned main 72d5e72e6 with the missing-result error. Two independent combined-workflow negative controls in perf(mcp): disclose retained-view guidance on demand #9353 reproduce the same failure before any compiled-guide lookup.

Combined qualification with #9353: 12 public stdio configurations cover legacy/modern, full/compact/off output advertisements, full/hot-cold catalogs and pairwise full/compact inputs. Two additional cases hold real deferred initialization, cancel one request, complete a peer, verify only the peer's Evidence was recorded, reconnect, and recover portable Evidence. Four further cases verify malformed-first-call recovery and lazy-module failure behavior on those same legacy/full and modern/hot-cold configurations. Two prompt-first cases additionally verify prompt-driven materialization and live retained-Evidence completion. Two runtime-copy cases additionally exercise stale/unavailable guidance union members, malformed locators, and recovery after restoring the bundle. All 22 pass. Modern refresh uses a real subscriptions/listen subscription; legacy uses unsolicited notifications. This is a representative matrix, not the exhaustive 24-cell product.

Legacy advertisements remain compared with the canonical generated catalog. Modern listings retain pre-codec projections. Successful union results, errors without structured success payloads, malformed compact inputs, repeated discovery and retained views all preserve their declared behavior.

Current-main qualification: #9353 head 454d7121f combined with pinned main c78c8aed4 in an unpublished worktree passes 79 MCP boundary and 53 source cases, including this PR's 35 public stdio cases and eager/deferred schema comparisons. Build, typecheck/lint and documentation checks pass. Missing generated test metadata initially blocked two suites; the focused runner prepared it before both suites passed. No combined CI claim; reproduction and limitations are recorded in #9353.

The once-dispatched combined CI at #9353 head 17e8deebf passed all 22 deferred cases but failed one guidance-search rank assertion; the current-head correction and its passing 28-case focused/acceptance validation are recorded at #9353 ed307b8d5. The real Apple job was cancelled at its workflow bound, so no full-run pass is claimed.

Related history: #7127, #9046, #9151, #7228. Scope decision: not applicable; existing schema presentation only. No token/latency saving claimed for this prerequisite. Real deep providers and other host platforms were not exercised.

Author readiness

Human owner: @kaoru0822-kitauji

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

@greptile-apps

greptile-apps Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge; no blocking code issue was found.

Summary

Records canonical output schemas before the SDK applies protocol-specific framing.

  • Deferred MCP tools advertise their canonical output shape.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  C[Canonical output schema] --> R[Catalog recorder]
  R --> J[Pre-framing JSON Schema]
  J --> D[Deferred SDK registration]
  C --> V[Canonical output checker]
  V --> D
  D --> S[SDK applies negotiated framing]
  S --> A[MCP client]
Loading

Reviews (4) · Last reviewed commit: "test(mcp): verify deferred parity and ca..." · Reviewed by Greptile

@kaoru0822-kitauji
kaoru0822-kitauji marked this pull request as ready for review November 12, 2026 13:50
@kaoru0822-kitauji
kaoru0822-kitauji merged commit bed3f0b into main Nov 12, 2026
55 of 60 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T13:55:30.976513Z 9304152 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Labels

area: mcp MCP server, transport, and tool registration bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants