Skip to content

fix(code-mode): preserve core coding signatures in bounded catalog - #166785

Merged
steipete merged 1 commit into
mainfrom
codex/stab-code-mode-shell-signature
Oct 7, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/stab-code-mode-shell-signature

Conversation

@steipete

@steipete steipete commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

In code mode, models routinely call the shell tool with cwd instead of workdir. The call fails with exec 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 -> output lines, and sorts tools with a declared output first. The core exec and process tools declare no output, so on a realistic 60-tool catalog both fell past the cap ("36 additional tools omitted"). A model writing catalog.search(...) plus the call in one cell therefore guessed the parameter names.

User Impact

  • Shell and process calls from code mode use the right parameter names on the first try: no failed tool rows, no wasted model round trip, lower latency and token use.
  • The index stays bounded and deterministic. The full description grew by 18 characters (about 5 tokens) on the 60-tool catalog, and the bundled prompt snapshots regenerate unchanged.

Why This Change Was Made

The rejection of cwd is 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 existing isCoreCodingSurfaceToolName policy and matched only on exact openclaw: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):

main 9aa74552   sessions with cwd rejection: 10/12   failed tool results: 20
this head       sessions with cwd rejection:  0/12   failed tool results: 0

Rendered index on a real 60-entry catalog: before, there was no exec or process line (index 7,975 chars); after, the exec { command: string; …; workdir?: string; … } and process lines are present (index 7,993 chars).

src/agents/code-mode.catalog-index.test.ts builds 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=1 passed 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. The cwd rejection, 8,000-character cap, and deterministic catalog ordering remain intact.

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.
@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S labels Oct 7, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 7, 2026
@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed October 7, 2026, 6:59 PM ET / 22:59 UTC (Revision 2).

ClawSweeper review

What this changes

Code 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
Reviewed head: 53207cf285d1164291defbee09fe3220b9a489cb

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, correct repair with strong real-provider evidence; the remaining reporting gap concerns the new regression’s measured cost.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured built-Gateway A/B campaign exercises the changed catalog description through fresh built-in-runtime sessions and real OpenAI shell tasks, showing zero cwd rejections after the fix versus 20 failed results before it. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured built-Gateway A/B campaign exercises the changed catalog description through fresh built-in-runtime sessions and real OpenAI shell tasks, showing zero cwd rejections after the fix versus 20 failed results before it. No stored-data contract changes.
Evidence reviewed 8 items Pinned introduced change: The introduced delta changes only catalog ordering, its regression test, and documentation. Exact core identities receive priority; the 8,000-character packing algorithm and execution path remain intact.
Current-main necessity: Fetched main still sorts declared-output tools ahead of unknown-output tools without prioritizing core coding signatures. The requested repair is therefore still absent. The supplied latest-release object could not be inspected locally, so release inclusion is not claimed.
Implementation boundary: The documentation explicitly distinguishes OpenClaw Code Mode from Codex Code Mode. This patch uses OpenClaw’s existing core-tool classification and catalog bindings; no dependency signal requires inspecting the Codex harness.
Findings None None.
Security None None.

How this fits together

OpenClaw 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]
Loading

Before merge

  • Complete next step (P2) - Add the measured wall time for pnpm test src/agents/code-mode.catalog-index.test.ts --maxWorkers=1 and the available CI seconds to the PR body.
Agent review details

Security

None.

PR surface

Source -3, Tests +88, Docs +2. Total +87 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 11 14 -3
Tests 1 88 0 +88
Docs 1 3 1 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 102 15 +87

Review metrics

None.

Technical review

Best 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.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs avoidable failed shell calls and extra model round trips in Code Mode without changing execution contracts.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured built-Gateway A/B campaign exercises the changed catalog description through fresh built-in-runtime sessions and real OpenAI shell tasks, showing zero cwd rejections after the fix versus 20 failed results before it. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured built-Gateway A/B campaign exercises the changed catalog description through fresh built-in-runtime sessions and real OpenAI shell tasks, showing zero cwd rejections after the fix versus 20 failed results before it. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduced change: The introduced delta changes only catalog ordering, its regression test, and documentation. Exact core identities receive priority; the 8,000-character packing algorithm and execution path remain intact. (src/agents/code-mode.ts:89, 53207cf285d1)
  • Current-main necessity: Fetched main still sorts declared-output tools ahead of unknown-output tools without prioritizing core coding signatures. The requested repair is therefore still absent. The supplied latest-release object could not be inspected locally, so release inclusion is not claimed. (src/agents/code-mode.ts:88, b300e0edea5e)
  • Implementation boundary: The documentation explicitly distinguishes OpenClaw Code Mode from Codex Code Mode. This patch uses OpenClaw’s existing core-tool classification and catalog bindings; no dependency signal requires inspecting the Codex harness. Public docs: docs/tools/code-mode.md. (docs/tools/code-mode.md:30, 53207cf285d1)
  • Real after-fix behavior: The captured PR body reports built dev Gateways, fresh built-in-runtime sessions, a real OpenAI provider, and identical shell prompts: cwd rejection fell from 10/12 sessions and 20 failed results to 0/12 and zero failures. The real 60-entry catalog gained visible exec and process signatures while remaining below 8,000 characters. Captured body identity: 304938b88aa07e01564d8c61593d677349b0191729c82cf2ce784f8fe3e094a3. (53207cf285d1)
  • Meaningful regression coverage: The new test constructs the real coding-tool catalog, forces overflow, verifies shell/file argument visibility and the index bound, and checks deterministic output under reversed input order. Existing tests independently cover declared-output priority, oversized entries, and client shadowing. (src/agents/code-mode.catalog-index.test.ts:10, 53207cf285d1)
  • Prior review requirement remains applicable: Repository test policy requires measured per-file cost and CI seconds. The previous completed review requested the new regression’s one-worker wall time; the captured body supplies only the aggregate 96-file duration. Live GitHub refresh was blocked, so no later resolution is asserted. Public docs: docs/help/testing/writing-tests.md. (docs/help/testing/writing-tests.md:108, 53207cf285d1)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record the new regression file’s one-worker wall time and CI seconds in the PR body.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-07T22:52:19.977Z sha 53207cf :: needs changes before merge. :: none

@steipete
steipete merged commit d794f3d into main Oct 7, 2026
137 of 139 checks passed
@steipete
steipete deleted the codex/stab-code-mode-shell-signature branch October 7, 2026 23:20
@steipete

steipete commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 8, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant