Repository navigation
fix(code-mode): preserve core coding signatures in bounded catalog - #166785
Conversation
Prioritize the existing core file and shell family before declared output hints so catalog growth cannot hide workdir, timeoutSeconds, or process timeout. Keep input validation, callable identity, and the 8000-character index budget unchanged.
|
🦞👀 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: needs changes before merge. Reviewed October 7, 2026, 6:59 PM ET / 22:59 UTC (Revision 2). ClawSweeper reviewWhat this changesCode Mode prioritizes core file and shell signatures in its bounded tool index, adds catalog-overflow regression coverage, and documents the ordering. Merge readiness⛔ Needs changes before merge - 1 item remains The fix remains useful on current main, with convincing live before/after evidence and no actionable patch defects found. The prior review’s test-cost reporting requirement remains outstanding. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw Code Mode turns enabled tool schemas into a compact index that models use when writing JavaScript tool calls. Index ordering determines which argument signatures remain visible when the catalog exceeds its prompt budget. flowchart TD
A[Enabled tool catalog] --> B[Effective callable bindings]
B --> C[Core coding tools first]
C --> D[Bounded signature index]
D --> E[Model writes JavaScript]
E --> F[Existing tool dispatch]
D --> G[Catalog search for omitted tools]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -3, Tests +88, Docs +2. Total +87 across 3 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep core coding argument signatures visible within the existing bounded catalog while preserving strict input validation and search access to omitted tools. Do we have a high-confidence way to reproduce the issue? Yes: source inspection establishes how a large declared-output catalog can hide shell signatures, and the captured real-provider A/B campaign demonstrates the failure. This review did not execute target code. Is this the best way to solve the issue? Yes: reusing the existing core-tool classification in the index owner is a narrow repair that preserves validation, callable identity, and the prompt budget. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b300e0edea5e. LabelsLabel changes: No label 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
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
…penclaw#166785) Prioritize the existing core file and shell family before declared output hints so catalog growth cannot hide workdir, timeoutSeconds, or process timeout. Keep input validation, callable identity, and the 8000-character index budget unchanged.
What Problem This Solves
In code mode, models routinely call the shell tool with
cwdinstead ofworkdir. The call fails withexec parameter "cwd" is unsupported; use "workdir" instead, the model spends another round trip retrying, and the Control UI shows "Worked · 2 failed" on a trivial turn. On main 9aa7455, 12 fresh built-in-runtime sessions doing one-line shell tasks produced the rejection in 10 of 12 sessions (20 failed tool results). Across this stability campaign's earlier transcripts, it hit 9 of 34 sessions that used the shell.The models were not ignoring documentation; they never saw it. Code mode renders a bounded (8,000-character) index of
callableName input -> outputlines, and sorts tools with a declared output first. The coreexecandprocesstools declare no output, so on a realistic 60-tool catalog both fell past the cap ("36 additional tools omitted"). A model writingcatalog.search(...)plus the call in one cell therefore guessed the parameter names.User Impact
Why This Change Was Made
The rejection of
cwdis intentional (#154248: silently dropping it ran commands in the wrong directory) and stays. The defect was in the index ordering. The core coding-surface tools (exec,process,read,write,edit,apply_patch) now sort first, identified with the existingisCoreCodingSurfaceToolNamepolicy and matched only on exactopenclaw:core:identities. They are followed by the existing declared-output and unknown-output tiers, with the same alphabetical order inside each tier. No alias, schema, or config change was made, and no prompt prose was added.Evidence
Live A/B (dev Gateways built from main 9aa7455 and from this head, fresh state, real OpenAI provider, built-in runtime, 12 concurrent sessions, same four one-line shell prompts):
Rendered index on a real 60-entry catalog: before, there was no
execorprocessline (index 7,975 chars); after, theexec { command: string; …; workdir?: string; … }andprocesslines are present (index 7,993 chars).src/agents/code-mode.catalog-index.test.tsbuilds the index from the real tool set with a catalog large enough to trigger truncation. It fails on main (no shell line) and passes here. The code-mode, tool-search, and exec test files plus the schema-hint and prompt-snapshot suites pass (96 files, 290.8 s).tsgo:core, oxlint, the docs check, and the import-cycle check (0) pass. Autoreview is clean through P2.Production +11/-14 in
src/agents/code-mode.ts, tests +88, docs +3/-1 (docs/tools/code-mode.md).Regression cost (exact head
53207cf285d1164291defbee09fe3220b9a489cb):/usr/bin/time -p pnpm test src/agents/code-mode.catalog-index.test.ts --maxWorkers=1passed in 42.19 s wall on macOS (Vitest 36.34 s, test body 730 ms; includes compiler verification/preparation). CI run 37698521828, attempt 1,checks-node-changed-5, passed this file under Bun in 22.19 s Vitest / 23.80 s wrapper, with a 435 ms test body. The cost is dominated by transforming/importing the real tool construction path needed to reproduce catalog overflow. The exact-head CI gate passed, including prompt snapshots.Landing verification: 39 tests passed across the catalog-index, Code Mode, and exec-path files (
scripts/pr review-tests); independent Codex autoreview was clean through P2. Thecwdrejection, 8,000-character cap, and deterministic catalog ordering remain intact.