Repository navigation
feat(mcp): compact input schema profile for size-capped providers (kimi-cli/Moonshot) - #1514
Merged
morluto merged 3 commits intoOct 10, 2026
Conversation
Moonshot's function-calling API rejects a request while any single tool parameters schema exceeds its literal serialized size cap, so clients such as kimi-cli fail every request while the default catalog is attached (#1484). Add an opt-in REA_MCP_INPUT_SCHEMA_PROFILE=compact server presentation. Each advertised input schema is rendered within a 13,312-byte budget, measured to sit below the observed provider cap: annotation prose (nested descriptions, examples, defaults, titles) is dropped, repeated annotation-free subschemas are shared through schema-local $defs/$ref references the provider validates without expansion, and the three structurally oversized schemas are advertised in a documented reduced form. The canonical catalog, tool set, output schemas, and server-side canonical validation are unchanged; the default full profile is byte-identical to today's advertisement. Boundary tests pin every compact schema to the budget, keep them valid JSON Schema that still accepts every canonical example, hold reduced presentations at three or fewer, and verify canonical rejection still guards a permissive advertisement. Verified against the real Moonshot API through kimi-cli: prompts succeed with the compact catalog attached where the default catalog fails every request with 400.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
darsrc
pushed a commit
to darsrc/rea
that referenced
this pull request
Oct 10, 2026
…mi-cli/Moonshot) (morluto#1514) * feat(mcp): add compact input schema profile for size-capped providers Moonshot's function-calling API rejects a request while any single tool parameters schema exceeds its literal serialized size cap, so clients such as kimi-cli fail every request while the default catalog is attached (morluto#1484). Add an opt-in REA_MCP_INPUT_SCHEMA_PROFILE=compact server presentation. Each advertised input schema is rendered within a 13,312-byte budget, measured to sit below the observed provider cap: annotation prose (nested descriptions, examples, defaults, titles) is dropped, repeated annotation-free subschemas are shared through schema-local $defs/$ref references the provider validates without expansion, and the three structurally oversized schemas are advertised in a documented reduced form. The canonical catalog, tool set, output schemas, and server-side canonical validation are unchanged; the default full profile is byte-identical to today's advertisement. Boundary tests pin every compact schema to the budget, keep them valid JSON Schema that still accepts every canonical example, hold reduced presentations at three or fewer, and verify canonical rejection still guards a permissive advertisement. Verified against the real Moonshot API through kimi-cli: prompts succeed with the compact catalog attached where the default catalog fails every request with 400. * fix(mcp): preserve compact schemas through Kimi conversion --------- Co-authored-by: morluto <[email protected]>
This was referenced Oct 10, 2026
Owner
|
Welcome, @haythemsellami. Thanks for working through the Kimi CLI/Moonshot failure and testing the compact profile against the real API. The opt-in setting gives people hitting that schema limit a way to keep using REA. |
2 tasks done
2 tasks done
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.
Fixes #1484
Problem
Moonshot's function-calling API rejects a request while any single tool
parametersschema exceeds its literal serialized size cap (community measurements bound it between ~13.7 KB accepted and ~15 KB rejected). Clients that forward every advertised tool on every request — kimi-cli today — fail every turn with400 tools.function.parameters is not a valid moonshot flavored json schema ... schema exceeds maximum allowed sizewhile REA is connected, even for unrelated prompts. On the default catalog, 44 of 139 advertised input schemas exceed that cap, the largest at ~87 KB.Change
Add an opt-in advertised-input presentation selected by the server environment variable
REA_MCP_INPUT_SCHEMA_PROFILE=compact(defaultfull, parsed and validated likeREA_MCP_MAX_RESPONSE_BYTES, read at startup). When active, each advertised input schema is rendered within a 13,312-byte budget — chosen to sit below the lowest observed accepted size:$defs/$ref, which the provider validates without expansion. Validation keywords, the root's input-group description, and literalconst/enumdata are untouched. The root's echoedexamplesare dropped with the other annotations.compare_web_captures,build_reconstruction_obligation_ledger,evaluate_reconstruction_coverage): property names, detected types, first-level guidance, and root required-field constraints, with nested validation detail elided and an explicit annotation that the advertisement is reduced.Unchanged by design, per #723's boundaries: the canonical catalog and tool set, output schemas, tool descriptions and annotations, the registered canonical Zod parsers, and server-side canonical validation. The default
fullprofile advertises byte-identical schemas tomain. The compaction is applied at theEvidenceMcpServerregistration seam and wraps any standard-schema registration, including plain non-Zod standard schemas such asinspect_web_network_capture's.Measured on the live 139-tool catalog: advertised input bytes 522,914 → 183,615 (−65%), every tool ≤ 13,312 bytes.
Validation
src/contracts/compactInputSchema.test.ts): annotation stripping keeps validation keywords and literal data, reference sharing resolves and reuses existing definitions, no self-referential definitions, determinism, reduced-tier shape and budget.mcpResponseBudget).tests/boundary/mcp/compactInputSchemaMcp.test.ts): loopback discovery of the complete catalog under the compact profile — every input schema within budget, Ajv 2020-12 valid, every canonical example still accepted, output schemas and descriptions byte-identical to the full profile, a ratchet holding reduced presentations at ≤ 3, canonical rejection of reserved arguments the (permissive) advertisement accepts, and the plain-standard-schema registration path.mcp-boundarylane: 325 passed (nativeDemangleMcprequires the host's realswift-demangle, unavailable in this sandbox and unrelated).docs:check, and skill/catalog artifact regeneration pass.npm run lintcarries the same pre-existing error onmain(JavaScriptSemanticGraphBuilder.tsmax-lines); this change adds no new lint errors.Usage
{ "mcpServers": { "rea": { "command": "npx", "args": ["-y", "rea-agents@latest", "mcp"], "env": { "REA_MCP_INPUT_SCHEMA_PROFILE": "compact" } } } }Open follow-ups outside this PR: reporting the active profile in
binary_sessionidentity, and a client-side graceful-degradation fix in kimi-cli (drop the oversized tool with a warning instead of failing every request) so one oversized server cannot brick the client.