Repository navigation
perf(discovery): select metadata before materializing tool contracts - #777
Conversation
yyjeqhc
left a comment
There was a problem hiding this comment.
Reviewed on the exact current head in special:/root/git/webcodex-review. The descriptor layer remains metadata-only and does not become an admission/authority source: exact specialists stay exact-only, operator extensions stay protocol-capability gated, and full ToolSpecs still use the canonical input/output schema and annotation builders. list_tools now selects/filter-limits before materializing returned full specs; exact ordinary tool_manifest materializes one input schema and no output schema; summary/category/sparse-description paths remain schema-free. Descriptor/full-spec parity and ordering are covered across ordinary, specialist and extension factories. Independent validation: contract crate all-features 264/264; targeted materialization boundary 1/1; all-feature tool_manifest selection 35/35; format/diff checks pass; GitHub CI is fully green across Linux, Windows, macOS, Docker and MCP conformance. I also reran the documented optional Code Mode exact-manifest case: read-only=8991 bytes and validation=13017 bytes, then guarded-edit fails at the unchanged 16 KiB bound exactly as documented/reproduced on the baseline; the test itself is unchanged in this PR and no limit/constraint was weakened. No blocking findings.
Scope and commits
Maintenance group 2 of 3. Independently based on
b967a1556ac58b50e32c8399196979fdbae1713c(#774), developed in special/root/git/webcodex-review. No dependency on the Runner test-isolation or Console/audit module PRs.a4552c83— schema-free descriptor selection; materialize full contracts only where required.1bdaae8e— materialization-boundary tests and remove redundant static full-schema rebuilding from the policy matrix without reducing its combinations.29318f16— documentation-only record of the baseline-confirmed optional Code Mode limitation.Behavior
The same canonical definitions and fixed extension descriptions now supply lightweight ToolDescriptors. Descriptors do not admit tools or grant authority. Ordinary exact tool_manifest builds only the requested input contract, no output schemas. Category/intent/summary discovery and filtered description projection use metadata without building full ToolSpecs. Full list_tools filters/limits first, then constructs returned specs. Full public schema APIs remain available and their content/order is unchanged.
Existing model visibility, exact-only specialists, capability-admitted operator extensions, permissions, routes, recommended flows, annotations and schemas retain their original semantics. Explicit experimental Code Mode callable contracts still request the full schemas they need. No new cache, dependency, configuration, tool or resource URI.
A test-thread-local counter checks requested schema materialization: exact ordinary lookup (1 input/0 output), category/summary/sparse description (0/0), full list limit1 (1/1), unadmitted Memory (0/0 and failure). These counts do not claim to change the canonical input schema's existing whole-enum OnceLock initialization.
Measurement
The expensive policy test retains all 2 Apps states × 2 Goal preferences × 3 resume declarations, and six exact manifest checks per cell. The static full-schema builder has no Runtime input, so its identical baseline is compared before/after the matrix instead of rebuilt in every cell.
One local unoptimized observation, excluding compilation: same test 54.79s before → 11.19s after. This measures the combined production-path and test duplicate-work improvements, not production latency percentiles, tokens or Host Code Mode throughput.
Validation
tool_manifestselection: 35 passed.git diff --exit-code 1bdaae8e HEAD -- src crates frontend.Explicit known optional failure — reproduced on unchanged baseline
The additional all-feature test
code_mode_exact_manifest_projects_canonical_stage_callable_contractsfails for self-hosted experimental guarded-edit Code Mode because its existing projection exceeds the existing 16 KiB hard bound. Read-only and validation stages produce 8,991 and 13,017 bytes respectively.The exact same test was run from a disposable immutable
git archiveof baselineb967a1556ac58b50e32c8399196979fdbae1713c; it fails identically with exit101 and the same successful-stage sizes. This is a pre-existing optional limitation, not introduced by this PR. The bound is not raised, no schema constraint/test is weakened, and the entire optional root suite is not described as passing. The next key-constraints command in the failed && chain did not run. Existing optionalObservedRunnerRequest.logindead-code warning remains.No production deployment/restart, native Windows/macOS run, full root all-feature suite or public API migration was performed. Details and measurement limits:
docs/implementation/on-demand-tool-discovery.md.Final HEAD:
29318f16911fb99d4f8cc0c30190547e2ba7b2f6; tree:926928a127dcc4f1414b4cbbf3482e09f7953110.