Repository navigation
fix: distinguish Code Mode guest errors after tool calls - #160217
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: needs changes before merge. Reviewed September 28, 2026, 9:39 AM ET / 13:39 UTC (Revision 5). ClawSweeper reviewWhat this changesThe branch tracks rejected tool errors across Code Mode’s Node and QuickJS executors, updates exec/wait regressions and troubleshooting guidance, removes a duplicate UI decoder, and repairs a CI test helper. Merge readiness⛔ Needs changes before merge - 1 item remains Keep open: current main still misclassifies guest errors after tool calls, and this branch provides a distinct fix. The earlier review findings are addressed. The required CI gate remains red. Priority: P2 Review scores
Verification
How this fits togetherCode Mode lets an agent call tools from JavaScript running in a Node or QuickJS worker. Its tool bridge returns outcomes to the worker, and exec/wait results report error origin and replay safety to the caller. flowchart LR
A[Agent JavaScript] --> B[Node or QuickJS worker]
B --> C[Tool bridge]
C --> D[Tool outcome]
B --> E[Error origin check]
D --> E
E --> F[Exec or wait result]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +21, Tests +169, Docs +5. Total +195 across 13 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep the shared controller as the error-origin owner, carry that fact through both executors, and report dispatch and replay safety independently in exec/wait results. Do we have a high-confidence way to reproduce the issue? Yes. Current main’s settlement override predicts the reported misclassification for a guest error after tool dispatch, and the branch’s exec/wait boundary cases exercise that path; this read-only review did not execute them. Is this the best way to solve the issue? Yes. Recording the rejected Error’s identity once in the shared controller gives both executors an origin fact without changing the separate replay-safety decision. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against baf2edda0d31. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
Co-authored-by: VACInc <[email protected]>
Same bounded inherited build repair tracked in openclaw#160187; keep the original decoder unchanged. Co-authored-by: VACInc <[email protected]>
Apply the existing main repair 6d18cb7. Both inherited GitHub/hybrid failures reproduce before and all three backend cases pass afterward. No production changes. Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: VACInc <[email protected]>
Use one captured Node serializer for observed and unhandled errors. Encode provenance in a null-prototype primitive record so guest JSON hooks cannot forge or erase bridge origin. Four Node regressions fail before the repair; all 30 cross-executor phase cases and 50 selected sibling cases pass after it. Co-authored-by: VACInc <[email protected]>
|
@clawsweeper re-review Head |
|
🦞👀 Re-review progress:
|
…0217) * fix: distinguish Code Mode guest errors after tool calls * fix(code-mode): preserve bridge identity and verify failure phases Co-authored-by: VACInc <[email protected]> * fix(ci): remove duplicate chat attachment decoder Same bounded inherited build repair tracked in openclaw#160187; keep the original decoder unchanged. Co-authored-by: VACInc <[email protected]> * test(ci): match canonical concurrency to the runner profile Apply the existing main repair 4217e8a. Both inherited GitHub/hybrid failures reproduce before and all three backend cases pass afterward. No production changes. Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: VACInc <[email protected]> * fix(code-mode): protect error provenance serialization Use one captured Node serializer for observed and unhandled errors. Encode provenance in a null-prototype primitive record so guest JSON hooks cannot forge or erase bridge origin. Four Node regressions fail before the repair; all 30 cross-executor phase cases and 50 selected sibling cases pass after it. Co-authored-by: VACInc <[email protected]> * fix: preserve Code Mode bridge origin through error getters --------- Co-authored-by: VACInc <[email protected]> Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
Summary
High Level TLDR
Fixes an issue where Code Mode callers see a guest JavaScript error reported as a tool-bridge failure after a tool call has already completed. Destructuring an object-returning tool result as an array is a guest error, not evidence that the tool failed.
User Impact
Callers can distinguish guest programming mistakes from rejected tool calls without treating completed side effects as safe to replay. A guest error can still have
bridgeDispatchStarted: trueandreplaySafe: false; inspect the destination before repeating an action. The troubleshooting guide explains this distinction.Root Cause
Before this PR, result settlement used bridge dispatch history to relabel later guest errors as bridge failures. The Node observer also read guest-controlled Error diagnostics before recording bridge identity; a throwing getter could prevent settlement and hide the rejected tool call's origin.
The shared controller records rejected bridge Error identities. Node and QuickJS retain that origin, and result settlement no longer replaces it with dispatch history. Captured WeakSet operations keep guest prototype changes from corrupting classification; original bridge identity takes precedence over module-looking error text. Node’s primary and unhandled errors share one private serializer with captured intrinsics and a null-prototype primitive record, so guest JSON hooks cannot relabel provenance.
One provenance owner serves inline execution and resumed snapshots. No configuration, storage, permission, or replay-policy changes. Code Mode production +66/-18 (combined production +66/-45 after the inherited build repair): identity tracking is needed because dispatch history and error text cannot distinguish rethrows from new guest errors.
The inherited build/typecheck blocker is also removed: a second, byte-identical export of the chat image decoder. The first decoder and all callers stay unchanged. This is the same bounded repair now landed in #160187 (4001998), not a visual or attachment-behavior change.
The interrupted full gate also exposed two inherited CI-planner test failures: the concurrency helper compared GitHub/hybrid groups against Blacksmith owners. This includes Peter Steinberger’s existing main repair
6d18cb7cd9f494d39b0d5541843eb6965486ece8without changing production code or weakening assertions. The two failures reproduce before the repair; all three backend cases pass afterward.Original implementation and contributor: @VACInc. Follow-up repairs preserve contributor ancestry and credit.
Verification
Real behavior proof
78d08ee976b74db10020375ac456c7a79d67e911: 10 expected guest-as-bridge failures and 8 controls passed through real Node/QuickJS exec/wait tools.2ddd897ab13236e30850069575485087c2d1aea9: all four Node/QuickJS cases failed before repair (mutable WeakSet operations and module-looking rethrows).a519bc344dc6f8523f94e432d956e534a9bc7d18: four Node serialization-hook cases failed, with four matching QuickJS controls passing. BothObject.prototype.toJSONhooks and replacementJSON.stringifycould forge/hide Node provenance, including after wait and on unhandled rejection.Latest ClawSweeper review repair
4feea94d14c82f1d8909f3d1c0e14f7986289394: a guest-defined throwingstackgetter could interrupt Node error encoding before the observer settled the original bridge rejection.execand resumedwaitregressions both returnedfailurePhase: "guest"on Node; matching QuickJS cases passed. After repair, all 34 failure-origin cases and 9 Node-worker sibling cases passed. Each case verifies one tool execution,bridgeDispatchStarted: true,replaySafe: false, and run cleanup.node scripts/check-changed.mjsandgit diff --checkpassed on this head.Review and test discipline
Measured test cost
Command:
node scripts/run-vitest.mjs <file> --maxWorkers=1, the repository wrapper behindpnpm test. Wall time includes setup/compilation.src/agents/code-mode.failure-phase.test.tscode-mode.preflight-repair.test.tscode-mode.result-budget.test.tscode-mode-nodes.test.tscode-mode-swarm.test.tsThe new cases need real workers and QuickJS snapshots; a pure helper test cannot prove serialization/continuation identity. Existing sibling setup is unchanged; edits update phase expectations and explicitly assert replay safety. Six unchanged sibling files passed in 62.11 seconds wall. CI test timings are unavailable because incoming CI stopped at preflight.
What was not tested
Publication gates
Native full build and static checks passed on published head
4feea94d14c82f1d8909f3d1c0e14f7986289394(and the earlier52c01dcandidate). The build completed with a nonfatal startup-JS size report 10 bytes over its reported budget; no budget was altered. The Blacksmith Testbox full test command on leasetbx_01m3kga6de5rrg0s1m8n1jb539(run) exited 255 after 7,263.620 seconds; there is no full-suite success receipt. Five completed top-level groups passed 32,892 tests with 53 skipped, then tooling reported the two inherited planner failures above. The provider/SSH termination cause remains unconfirmed; the lease is stopped. The two assertion failures are independently reproduced and repaired, not dismissed as flakes.Focused fixture proof:
node scripts/run-vitest.mjs test/scripts/ci-changed-node-test-plan.test.ts -t "keeps the complete Git tooling family": before 2 failed/1 passed (5.22 seconds wrapper); after 3 passed (5.40 seconds wrapper, 3.808 seconds test work). This fixture repair adds no new test cases, retries, timeout increases, or configuration.Prior published head:
4feea94d14c82f1d8909f3d1c0e14f7986289394. The source-verified Testbox run was stopped after a completed agent-core shard reported four failures: the MCP transport-settlement fixture expected["probe"]but received an empty catalog, after approximately 30 seconds per case. The stack reaches the survivor-fixture setup before the local command executes (agent-command-local.test.ts:174). These are catalog assertion failures, not Vitest timeout verdicts. That shard reported 4 failed / 1,780 passed / 3 skipped tests; the overall 685-shard suite did not complete and has no success receipt. Its owned lease is stopped.The failing test, local-command entry point, and MCP manager API/manager/runtime are byte-identical to protected main
2da0e9a4c85b4976d0c6ac56b3dab57e88f859f6. Root cause remains under investigation; source equality is not a claim that a main replay passed. A local isolated probe was blocked before any tests by the live-Gateway runtime-artifact publication guard, so the original shard is being investigated in isolation on Testbox. No assertions were weakened or timeouts increased.The prior CI run finished red on two Control UI E2E assertions (
chat-motionandsession-progress-widget); no Code Mode job failed. This PR changes no code in either failing test or its owning UI flow apart from removing an unused chat image decoder, but source separation alone does not prove those failures independent. No assertion or timeout was weakened, and the failures are not called fixed.Current published head:
7f4900adbc581d580be9f358710974bc0449cefb. Fresh ClawSweeper Revision 4 reviewed this exact head and marked it ready for maintainer review with no actionable patch finding. Its CI run completed red: UI E2E shards 3/9 and 4/9 failed (chat-run-lifecycle,session-progress-widget, andchat-user-bubble-disclosure). The exact CI merge commit has the sameui/tree as its main parent, so this PR contributes no UI source to those failing checks. A local full replay of UI shard 4/8 passed both CI-failing shard-4 tests but failedboard-fixtureon a four-millisecondsnapshotAtmismatch. These observations show the failed UI source predates this PR; they do not establish a safe fix. The requiredopenclaw/ci-gatefailed, so CI is not green. No failing assertion or timeout was weakened.Inherited CI failures (admin exception)
Exact-head run 36425181979 is red only in
checks-ui-e2e (3/9)and(4/9):chat-run-lifecycle("refreshes cached direct activity after a session-only mock-Gateway Stop"),session-progress-widget("keeps target liveness when the selected agent scope changes"), andchat-user-bubble-disclosure("remeasures the fifth line after viewport and text reflow"). All run against the in-browser mock Gateway, fail on multiple unrelated PRs and on main's UI e2e cluster today, and are in files this PR does not touch; the CI merge commit'sui/tree is byte-identical to its main parent. ClawSweeper Revision 5 reports no findings. Landed under the AGENTS.md pre-existing-red exception by the maintainer.