Repository navigation
improve: prepare MCP prompt names without rendering tool APIs - #146083
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 12, 2026, 11:15 AM ET / 15:15 UTC. ClawSweeper reviewWhat this changesThe PR lets OpenClaw Code Mode prepare MCP server names without constructing callable tools or rendering their parameter documentation, while retaining those operations for execution. Merge readiness⛔ Blocked before merge - 2 items remain This remains a useful, focused optimization: current main still performs the unnecessary schema work. No introduced correctness or security defect was found, and the maintainer-protected PR should remain open. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw Code Mode turns the available tool catalog into model instructions and an executable tool namespace. MCP server naming feeds both the prompt and the runtime API declarations. flowchart TD
A[Available MCP tool catalog] --> B[Shared server naming plan]
B --> C[Prompt server list]
B --> D[Runtime namespace construction]
D --> E[Parameter documentation and API files]
D --> F[Guarded tool invocation]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +13, Tests +24. Total +37 across 2 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep server naming under one shared planner and reserve schema documentation and callable construction for runtime preparation. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the unnecessary work: catalog preparation and refresh call the prompt renderer, which on main constructs parameter documentation before selecting server names. No runtime benchmark was executed during this read-only review. Is this the best way to solve the issue? Yes. Sharing the existing naming algorithm removes unused preparation work without introducing a competing naming policy or changing the runtime tool contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 99be6bd6a27b. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
What Problem This Solves
Preparing the Code Mode prompt for an MCP catalog builds tool scopes and recursively renders parameter documentation merely to list the available servers. Large catalogs repeat this unused work whenever the catalog refreshes.
Why This Change Was Made
Share the existing server grouping and naming plan between prompt preparation and runtime construction. Prompt preparation consumes the server names directly; runtime construction still prepares callable tools and their API documentation.
User Impact
Code Mode catalog preparation and refresh become faster, with identical prompt text, server names, callable namespaces, and generated API files.
Evidence
562b3186c7d84717a38d788cc1721e7f3d67a657. Local focused proof passed; broad gates used hosted CI.Actual catalog operations, median seconds per operation:
The full matrix includes 0, 2, 100, 500, and 2,000 tools with simple and nested schemas. Two-tool cases improve on both runtimes. Empty-catalog refresh is unchanged; empty apply is approximately 9.8 → 9.6 microseconds on Node 24 and 9.7 → 10.7 microseconds on Node 26. That small absolute control cost is included rather than claiming every case improves.
Measurements ran on Windows 11 / AMD Ryzen AI MAX+ 395, using 15 warmup operations per variant and nine alternating before/after rounds, with 1,000 operations per small-catalog sample, 100 at 100 tools, and 10 at larger sizes. Full prompt bytes, namespace descriptors, and every runtime API file match, including twelve name-collision/order rotations, restriction, and rebinding. Synthetic nested schemas contain twelve array parameters with eight object fields each.
Fresh-process memory proof used before/after/after/before ordering per runtime, each running an initial apply plus 20 repeated applies over 2,000 nested-schema tools. Peak RSS was inconclusive: Node 24 measured 576–608 MiB before versus 603–645 MiB after; Node 26 measured 534–542 MiB before versus 520–542 MiB after. Cold-import working sets varied substantially, so this PR makes no claim of lower peak RSS. Observed heap-used growth from the post-import/preparation checkpoint to the post-work snapshot fell from 125–254 MiB to about 41 MiB on Node 24, and from about 222 MiB to 12 MiB on Node 26. These are heap snapshots without a final collection, not retained-heap or total-allocation measurements. The two runtimes' memory-only sequences ran concurrently; their elapsed times are excluded from latency evidence.
The performance harness runs actual Code Mode catalog application and refresh using synthetic MCP catalogs. It checks complete prompt text and runtime API files. Timings measure catalog preparation, excluding MCP server/network latency.