improve: reduce Code Mode catalog discovery turns#109651
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 17, 2026, 12:52 AM ET / 04:52 UTC. Summary PR surface: Source +58, Tests +82, Docs +15. Total +155 across 4 files. Reproducibility: not applicable. as a conventional bug reproduction; the performance opportunity is demonstrated through an exact-branch live multi-provider benchmark against the merged predecessor. Review metrics: 1 noteworthy metric.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the shared, bounded native-tool index after refreshing it onto current main and confirming exact-head checks, while retaining deferred descriptions, full schemas, MCP entries, and overflow lookup inside the guest runtime. Do we have a high-confidence way to reproduce the issue? Not applicable as a conventional bug reproduction; the performance opportunity is demonstrated through an exact-branch live multi-provider benchmark against the merged predecessor. Is this the best way to solve the issue? Yes. Reusing the compact catalog formatter and exposing only a deterministic bounded index is narrower and safer than adding configuration or moving full schemas and untrusted descriptions into the model prompt. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a77c0770ffe6. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +58, Tests +82, Docs +15. Total +155 across 4 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
Merged via squash.
|
Related: #109288
Follow-up to #109596
AI-assisted: Yes (Codex)
What Problem This Solves
Code Mode kept its compact tool catalog entirely inside the guest runtime. Models therefore spent an initial
execturn discovering exact tool ids, or guessed nonexistent ids and used more turns to recover, before useful work began.Why This Change Was Made
The model-visible
execdescription now carries a deterministic, 8,000-character quick index of exact OpenClaw/plugin catalog ids and compact input hints. Full schemas, descriptions, MCP entries, and overflow entries remain deferred to guest-side catalog lookup, which preserves the bounded prompt and avoids exposing adversarial catalog prose.The index marks result schemas as unknown. When output fields are not documented, guidance asks the model to return the raw value first and process the observed shape in a later
execinstead of guessing fields. A shared compact-entry formatter keeps the prompt index and guest catalog representation aligned.User Impact
Code Mode can begin common tool workflows without a separate catalog-discovery round trip. Across the 72-tool adversarial live harness, it used fewer turns, tool calls, tokens, and wall-clock time while improving validated task success and keeping decoy calls at zero.
Evidence
Live multi-provider Code Mode matrix, four validated tasks per provider, 72-tool catalog with adversarial decoys. Baseline is merged #109596; after is this branch. These are single live matrix runs, so provider latency and exact success counts remain stochastic.
Provider aggregates:
The nonexistent-tool recovery task passed on all three providers. No provider called an adversarial decoy.
Validation:
node scripts/run-vitest.mjs src/agents/code-mode.test.ts src/agents/tool-search.test.ts: 129 tests passed.node scripts/check-changed.mjs -- src/agents/code-mode.ts src/agents/code-mode.test.ts src/agents/tool-search.ts docs/reference/code-mode.md: delegated Testbox run passed, including core/test typechecks, formatting, lint, API surface, dependency, boundary, and runtime guards.