Repository navigation
perf(agents): preserve cross-run Code Mode prompt prefixes - #170282
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
|
|
Codex review: needs changes before merge. What this changesThis PR moves changing Code Mode catalog guidance from tool descriptions into the prompt after its stable prefix. Example: A second Code Mode run adds stamp_beta alongside stamp_alpha.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 2 items remain Keep this PR open: it addresses a current prompt-prefix problem with a simpler ownership model, but two diff-caused test failures and another stale assertion need repair. Priority: P2 Before merge
Findings
Agent review detailsHow this fits togetherAgent tool assembly prepares a policy-filtered catalog; prompt projection presents its callable contracts to the model, while Code Mode execution dispatches through the current catalog. flowchart TD
A[Enabled tools] --> B[Policy filtered catalog]
B --> C[Stable control schemas]
B --> D[Current catalog prompt]
C --> E[Provider request]
D --> E
E --> F[Code Mode execution]
B --> F
Technical reviewBest possible solution: Complete the test cutover while retaining stable control schemas, current catalog guidance, and unchanged execution authority. Do we have a high-confidence way to reproduce the issue? Current-main source establishes catalog-driven declaration changes, and CI annotations directly establish two introduced test failures; no target code was executed during this review. Is this the best way to solve the issue? Moving current guidance into the existing prompt owner avoids stale session stamps and duplicate synchronization, but the remaining test consumers must follow that cutover. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against be7696c5e9bc. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource -51, Tests +83, Docs +4. Total +36 across 25 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 12, 2026, 6:04 PM ET / 22:04 UTC. |
|
Both findings are fixed in b61dbfc: collector and shell host-contract assertions now read the current catalog prompt, and the mutable-description fixture uses a neutral tool name. The three affected files pass locally (47 tests), the follow-up independent review is clean, and the exact-head CI run is green: https://github.com/openclaw/openclaw/actions/runs/38315040682. |
…170282) * perf(agents): preserve cross-run Code Mode prompt prefixes * test(agents): follow current Code Mode catalog guidance
What Problem This Solves
Code Mode rewrites the
exectool description when MCP, plugin, client, or permission-filtered catalog entries change between runs. That invalidates the tool-schema prefix of an otherwise reusable conversation.User Impact
Consecutive runs retain identical Code Mode control schemas while receiving the current callable index and capability guidance after the stable prompt prefix. Execution still uses the current catalog and permissions. No configuration, schema migration, or operator action is required.
Why This Change Was Made
Move the bounded catalog index and catalog-dependent MCP, skills, nodes, and Swarm guidance into the existing prompt projection, for both embedded and worker harnesses. The existing session prompt owner appends changed sections on supported native Anthropic/Responses routes. Delete the description observer and wrapper synchronization machinery instead of retaining two sources of catalog guidance.
Current main already retains refreshed system/suffix sections and append-only failed-turn replay. Added serialized Anthropic/Responses regressions cover all reported section names, error/aborted assistant turns, staged user input, operator context, and diagnostics staying off-wire; no speculative second replay mechanism is added.
Evidence
Synthetic byte measurement against the original production renderer at
36e78f215f1f, 20 runs with 70 tools and one changing entry: serialized common tool-schema projection changes 19/19 → 0/19; tool-schema size 7,335 → 3,942 bytes (46% smaller). Changing the Code Mode index also changes the original system prefix but leaves the new 4,942-byte prefix identical while retaining current guidance. These measure bytes and prefix stability, not provider cache-hit rates or latency.Production diff: 80 insertions, 131 deletions (net −51 lines), excluding tests, test support, and docs.
Local proof: changed-file
oxfmt, repository oxlint on changed TypeScript files, andgit diff --checkpass. Independent review is clean through P2.pnpm test src/agents/code-mode.test.ts src/agents/code-mode.catalog-index.test.ts src/agents/system-prompt.test.ts src/agents/embedded-agent-runner/run/attempt.llm-boundary.cache-stability.test.ts --maxWorkers=1: 113 tests passed, 274.44 s cold wall time (catalog shard 110.88 s; serialized-request shard 24.54 s; Code Mode/system-prompt shard 114.79 s). The new schema-equality test took 3 ms; new error/operator cases took 2–7 ms each.src/agents/harness/tool-surface-bridge.test.ts(initial focused run, also using--maxWorkers=1): 33 tests passed, 195.05 s cold shard wall time, dominated by compilation. This was an earlier combined command; its subsequent new replay fixture assertions failed because a low-level adapter was expected to emit the native transport's role. The fixture now uses the native transport and passes above.Initial overlapping edits caused cold-compiler source-change failures before tests; no such run is counted as proof. Additional focused proof after CI found stale test expectations:
pnpm test src/agents/tools/agents-wait-tool.test.ts --maxWorkers=1: 31 passed, 100.79 s cold wall time.pnpm test src/agents/bash-tools.exec-host-contract.test.ts src/agents/system-prompt-report.tool-digest-cache.test.ts --maxWorkers=1: 16 passed, 144.10 s wall time. The test-only follow-up also passed independent P2 review.193 focused tests pass locally. Initial CI identified remaining collector/shell expectations that read the retired description index, plus a summary fixture that unintentionally invoked shell-description augmentation. Those are corrected without changing production code. Final-head CI run 38315040682 passed on
b61dbfce7711a92b537505ca2b5bd40ff1f0a751in 913 wall seconds; all required checks, includingopenclaw/ci-gate, are green. Full typecheck, broad suites, and remaining sibling coverage run in PR CI. No Testbox/Crabbox lease was allocated. The Linux benchmark rig was unreachable over SSH; Team was untouched. No live provider latency/cache-hit measurement is claimed.