#13302
[Design] MCP/CLI schema compaction, Evidence wire projection, and pagination contract roadmap
Before submitting
- I searched the open and closed issues and pull requests for a related discussion (#13275, #1065).
- I understand the contribution scope must be reviewed before integration; open questions are welcome here.
- This discussion does not include credentials, private samples, or sensitive target data.
Decision needed
Follow-up to #13275 based on live tools/list schema measurements across all 263 REA tools. Should REA adopt four contract-level improvements to cut agent prompt overhead, prevent oversized inline dumps, and stop 23 Evidence-consuming tools from collapsing into uninformative reduced schemas:
- Wrap
evidenceSchemainsideevidenceInputSchema(src/domain/evidenceReference.ts:32-34) withpresentCompleteObservation(matchingbrowserScenarioDiffValues.ts/webCaptureDiffSchemas.ts), - Switch high-volume search/inventory/trace tools from
detail: "complete"default (src/contracts/analysisDetail.ts:8) todetail: "summary"and/or exposeoffset/limit/viewpaging, - Eliminate the
reduceToShallowPropertiesdescription paradox & Depth-10 full-schema collapse (avoid re-emitting stripped property prose onreducedinputs and reduce only over-depth sub-branches instead of the whole root schema), and - Compact high-byte advertised schema surfaces (
update_analysis_settings, inlineviewunions, repeateddetailprose,output=compactenvelope repetition) and make canonicaladvertisedInputExamples/ output$iddigests lazy or opt-in (src/contracts/toolSchemaMetadata.ts)?
Context and evidence
Live tools/list Byte Measurements (dist/, Node v24.22.1, 263 tools)
(Exact UTF-8 JSON bytes; no tokenizer proxy claimed as exact LLM token counts.)
fullcatalog /output=off(default): 352,285 B total (description: 141,120 B / 40.1%,inputSchema: 159,178 B / 45.2%,annotations: 23,532 B / 6.7%,title+name: 11,612 B, JSON framing: 16,843 B).fullcatalog /output=compact: 671,130 B total (outputSchema: 314,637 B / 46.9%; 234 of 263 outputs reduced).hot-coldcatalog /output=off: 7,549 B total across 5 initial tools (open_binary,binary_session,get_evidence_bundle,close_binary,discover_tools).- Pre-compaction canonical schemas: input schemas total 1,500,420 B → compacted to 159,178 B (230
inline, 33reduced); output schemas total 5,048,287 B (12,985$defs).
Concrete Contract Defects Found
- Missing
presentCompleteObservationonevidenceInputSchema(src/domain/evidenceReference.ts:32-34):- Every tool taking
evidenceInputSchemainlines ~20.7 KiB of fullevidenceSchemaper Evidence parameter, overflowing the 13 KiB per-tool budget on 23 tools (inspect_analysis_view,trace_application_feature,trace_javascript_semantics,compare_process_captures,compare_wasm_interfaces,import_managed_reconstruction, etc.). compactAdvertisedInputSchemathen falls back toreduceToShallowProperties, erasing enums, literal types, and non-Evidence parameter structure AND erasing the{"kind":"retained-evidence","evidence_id":"ev_..."}variant itself.
- Every tool taking
- High-volume tools defaulting to
detail: "complete"(src/contracts/analysisDetail.ts:8) or lacking paging:- Of 31
detail-capable tools, 28 default to"complete"(onlyanalyze_functionandinspect_il2cpp_metadatadefault to"summary"), causing default calls onlist_strings,search_strings,list_procedures,search_procedures,list_names,get_call_graph,trace_feature,inspect_binary_layout,inspect_managed_members, etc. to attempt complete inline serialization. - Additional list/search/trace tools (
search_android_classes,trace_android_references,get_objc_classes,analyze_swift_types,list_frida_processes,list_adb_*,procedure_assembly) expose neitherdetailnoroffset/limit/view.
- Of 31
reduceToShallowPropertiesdescription paradox & Depth-10 cliff:- The 230
inlinetools strip per-propertydescriptionfields (exceptdetail), whereas the 33reducedtools fall back using the unstripped schema and emit 12,576 B of property descriptions (makinganalyze_web_bundleat 4,755 B reduced the #2 largest advertised input schema). - 6 tools well under the 13 KiB cap (
analyze_web_bundle,analyze_javascript_application,start_build_computer,verify_reconstruction,check_build_task,export_build_environment) collapse purely because nesting depth exceedsCOMPACT_SCHEMA_MAX_DEPTH = 10.
- The 230
- Top wire-size drivers & unused eager canonical work:
update_analysis_settingsalone is 10,146 B inline (18–33 per-setting branches vs one canonical schema + compact wire union{ setting: enum[...], action: "set"|"reset", value? }).- 10 inline
viewunions account for 20,674 B (13.0% of allinputSchemabytes); 37 retaineddetaildescriptions repeat 9,231 B (27 copies ofanalysisDetailSchema's 234-byte text). output=compactrepeatsOUTPUT_REDUCED_ANNOTATION233x (~31.7 KiB) and"$schema"262x (~15.2 KiB), plus ~220 copies of the 19-fieldEvidenceroot properties (~1.3 KiB each).toolInputSchemaWithMetadata(src/contracts/toolSchemaMetadata.ts:151) computes 319advertisedInputExamples(~35.7 KiB) on every contract even thoughcompactInputSchemastripsexamples, andtoolOutputSchemaWithMetadata(line 216) digests 5.05 MB of canonical output schema for$ideven whenoutput=offoroutput=compactdrops$id.search_guidance/read_guidance_sectionwrap live output in{ result: ... }while canonicaloutputSchemais a rootoneOf, causing a minor live-vs-catalogoutput=compactdiscrepancy.- Follow-up build/CLI items from
#13275: pre-generatingdist/mcp-catalog-compact-outputs.jsonsoREA_MCP_OUTPUT_SCHEMA_PROFILE=compactstays deferred at startup, and per-command splitting ofbinaryDiagnosticsCommands.ts.
Expected interaction with targets
- No target interaction (documentation or usability only)
Boundary details (optional)
- Canonical Zod schemas remain the single runtime validation owner for inputs and outputs; advertised schema changes must preserve
validateAdvertisedSchemadialect guarantees (advertisedInputDialectViolations) and keep canonical error recovery actionable when inputs fail full server-side constraints. - Changing default
detailfrom"complete"to"summary"is a user-visible MCP/CLI contract change requiring maintainer alignment (and updating callers/tests/docs that assume complete inline output whendetailis omitted).
Options and tradeoffs
- Option A (
presentCompleteObservationonevidenceInputSchema): Keeps non-Evidence parameter schemas & enums intact across the 23 affected tools and exposesretained-evidencecleanly, at the cost of modestly increasingfullinputSchemabytes (~350 B reduced → ~1.5–8 KiB inline) while adding 0 B inhot-cold. - Option B (
detail: "summary"default +offset/limiton high-volume native/Android/Frida tools): Prevents accidental multi-megabyte default replies and extrainspect_analysis_viewround-trips, requiring a coordinated contract/test transition. - Option C (Subtree-only depth pruning + consistent annotation stripping in
reduceToShallowProperties): Keeps root/sibling fields intact on the 6 depth->10 tools and removes the 12.6 KiBreduceddescription paradox.
Verification available so far
- I have a prototype or observed results
Success criteria and open questions
- Should
evidenceInputSchemaadoptpresentCompleteObservationso 23 Evidence-consuming tools stop collapsing intoreducedstubs? - Which high-volume search/list tools should standardize on
detail: "summary"default and/or directoffset/limitpagination? - Should
update_analysis_settingsand repeated inlineviewunions keep strict validation server-side while advertising a single flattened union on the MCP wire?
References
Activity
0No activity yet.