Repository navigation
fix: keep Code Mode tasks running after tool failures - #138044
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 4, 2026, 6:45 AM ET / 10:45 UTC. ClawSweeper reviewWhat this changesThe branch removes Code Mode’s special post-error reconciliation and restores ordinary model turns and tool availability after failed cells, with regression, documentation, QA-reference, and Android-test updates. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 2 items remain Keep open. This active maintainer-owned PR removes a current-main recovery policy that still terminates failed Code Mode cells; the reviewed patch coherently returns those failures to the normal agent loop and has no discrete correctness finding. Priority: P2 Review scores
Verification
How this fits togetherCode Mode executes guest JavaScript that calls OpenClaw tools through the embedded agent runner. Tool outcomes feed back into the agent loop, which either requests another model turn or finalizes the user-facing run. flowchart LR
A[User task] --> B[Model turn]
B --> C[Code Mode cell]
C --> D[Tool bridge and lifecycle]
D --> E[Failed or successful tool result]
E --> F[Normal agent loop]
F --> G[Next model turn or final reply]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -784, Tests -1075, Docs -26, Other +2. Total -1883 across 63 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one canonical normal continuation path after failed Code Mode cells, retain existing terminal, cancellation, policy, approval, and whole-run replay protections, and land after normal exact-head validation completes. Do we have a high-confidence way to reproduce the issue? Yes: the new focused embedded-runner scenario precisely exercises a partial failure followed by inspection and multiple edits on the ordinary Code Mode surface; it was source-reviewed but not executed in this read-only environment. Is this the best way to solve the issue? Yes: deleting the recovery owner and its private provenance plumbing is the cleanest solution because agent core already owns normal failed-tool continuation and retains terminal/tool-policy behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 329c6f907f68. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
Remove forced read-only reconciliation, recovery_resume, and the one-mutation continuation limit. Failed cells return to the normal agent loop so users can inspect partial effects and complete multi-step work with their configured tools. Preserve cancellation, permissions, explicit terminal outcomes, lifecycle receipts, and automatic whole-run replay protection.
A startup WebSocket request can reach MockWebServer after Stop retires it, causing the foreground-reentry assertion to report a reconnect that never happened. Reuse the existing call-through session shadow to observe actual connection admissions while preserving the real runtime and offline checks. The same test bytes have a reproduced before failure, a rejected deliberate reconnect, and 134 passing service/session sibling tests. Android lint passes; the updated PR CI will verify this candidate before landing.
76068c3 to
9685c7f
Compare
|
Merged via squash.
|
* fix(gateway): recover in-flight replies across restart Bind reply and session admission ownership to the Gateway host, including lifetime-wrapped plugin dispatch and queued delivery retries. Mark exact active owners durably, revalidate at commit and cancellation, then abort retiring parents before tool and channel teardown. The unchanged Linux scenario now completes three restarts with three retained recovery policies and one final delivery in 19 seconds. * fix(test): keep Gateway admission on the fixture lifecycle generation Expose the registry generation from the same mutable fixture state used by agent events and lifecycle rotation. Gateway agent-handler admission now reaches the intended behavior assertions after the restart ownership fix. * test: reuse isolated memory tools in recall tracking Adopt the already-landed canonical fixture repair from #138123 so the Gateway restart forward-port can run its memory CI shard without loading real plugins in the first recall-tracking case. Preserve all assertions, test order, and deadlines. No production changes. Source: 0209921 Validation: all four recall cases in original order; complete changed-file gate including extension test types, lint, and dead-export scans; independent P0-P2 review clean. * test(qa): refresh ClawHub release policy docs reference Adopt the canonical fixture correction from #138044 (085641a) after main removed the former publishing page. Scenario behavior stays unchanged. Verified all 58 catalog tests, complete changed-file checks, and independent review.
* fix: keep Code Mode tasks running after tool failures Remove forced read-only reconciliation, recovery_resume, and the one-mutation continuation limit. Failed cells return to the normal agent loop so users can inspect partial effects and complete multi-step work with their configured tools. Preserve cancellation, permissions, explicit terminal outcomes, lifecycle receipts, and automatic whole-run replay protection. * style: format Code Mode callback with pinned oxfmt * test: update failed-tool QA references after recovery removal * test(android): observe connection admission after stop A startup WebSocket request can reach MockWebServer after Stop retires it, causing the foreground-reentry assertion to report a reconnect that never happened. Reuse the existing call-through session shadow to observe actual connection admissions while preserving the real runtime and offline checks. The same test bytes have a reproduced before failure, a rejected deliberate reconnect, and 134 passing service/session sibling tests. Android lint passes; the updated PR CI will verify this candidate before landing. * test: repair ClawHub QA documentation reference
* fix(gateway): recover in-flight replies across restart Bind reply and session admission ownership to the Gateway host, including lifetime-wrapped plugin dispatch and queued delivery retries. Mark exact active owners durably, revalidate at commit and cancellation, then abort retiring parents before tool and channel teardown. The unchanged Linux scenario now completes three restarts with three retained recovery policies and one final delivery in 19 seconds. * fix(test): keep Gateway admission on the fixture lifecycle generation Expose the registry generation from the same mutable fixture state used by agent events and lifecycle rotation. Gateway agent-handler admission now reaches the intended behavior assertions after the restart ownership fix. * test: reuse isolated memory tools in recall tracking Adopt the already-landed canonical fixture repair from openclaw#138123 so the Gateway restart forward-port can run its memory CI shard without loading real plugins in the first recall-tracking case. Preserve all assertions, test order, and deadlines. No production changes. Source: 2fddacd Validation: all four recall cases in original order; complete changed-file gate including extension test types, lint, and dead-export scans; independent P0-P2 review clean. * test(qa): refresh ClawHub release policy docs reference Adopt the canonical fixture correction from openclaw#138044 (62e4d4d) after main removed the former publishing page. Scenario behavior stays unchanged. Verified all 58 catalog tests, complete changed-file checks, and independent review.
What Problem This Solves
Fixes an issue where users working in Code Mode could get stuck after a tool failure, even with Full Access. A source-inspection shell command could consume the recovery path's single mutation allowance, leaving the agent unable to finish the requested edits.
Related: #131340, #132437. Removes the continuation policy introduced by #128071 and #132583.
Why This Change Was Made
Removes forced read-only reconciliation,
recovery_resume, the one-mutation limit, exact-repeat fencing, tool-surface overrides, and their private provenance plumbing. Failed cells return through the normal agent loop, so the model can inspect partial effects and continue with its configured tools. This is the maintainer-requested complete removal of the policy.Normal permissions, approvals, cancellation, execution ownership, explicit terminal outcomes, public lifecycle receipts, and separate automatic whole-run replay protection remain. OpenClaw asks the model for its next action after an error; it does not automatically rerun the failed program. Model-selected repetition has the same partial-effect risk as ordinary tool use, and the documentation requires inspecting authoritative state before repeating work.
User Impact
Multi-step tasks can finish in the same session after recoverable Code Mode errors. There is no extra recovery mode, budget, setting, or permission-mode exception to manage. The Code Mode docs describe ordinary continuation and inspection of partial effects.
Evidence
Final CI: Required CI run33863730356 passes on
b5287705391586f47de0f446fa487dec88ff81bf:119 successful jobs,14 intentional skips, including all six Android jobs andopenclaw/ci-gate.Before/after: the byte-identical final embedded-runner regression fails against
0ff5f24d73349e1bae464bb990e05e9f07fc0e11: six model turns expected, one observed. It uses the original production hook installation. It and the real-file worker regression pass after removal.Tests: 761 tests across 30 selected files pass, covering continuation, sandbox/approval denials, cancellation, explicit terminal outcomes, nested lifecycle records, harness selection, suspended/headless Code Mode, whole-run replay safety, and the QA catalog/retained-reply flows.
Live: real
agent exec,openai/gpt-5.6-sol, QuickJS, and filesystem in Blacksmith Testbox. A first write succeeded, its outer cell deliberately failed, then the model inspected state, completed two later writes in distinct cells, and verified all three files. Six assistant turns, seven nested calls, 12/12 assertions passed; the first write happened exactly once and the failed result retainedisError: true. Live run. Temporary lease stopped.Source identity: the live run verified all 60 changed paths against manifest
2c0f1d18cfb797ceffce5a37c8714f150ba3800c160f2dbfc6527e6ed35a175d, matching commit7d8f18bbdae6b4e8cdaafac7dbbd321182573716. Follow-ups use pinned oxfmt 0.65 to format one callback (identical TypeScript syntax tree) update two QA catalog source references, and correct an Android test observation race. These follow-ups do not change production behavior; QA scenario execution and assertions are unchanged.Build/checks before rebase: clean local
build-all.mts sourcePerformancepasses, including 90 plugin builds and 53 native control-plane module loads. Core/extension typechecks, lint, formatting, boundaries, unused-export scans, and remaining guards pass. CI before rebase is green on76068c36d2e6ea7ebffdc78b258a7a648c203b47: 119 passing jobs, 14 intentional skips. The failed-job-only retry cleared an npm advisory outage and interrupted Matrix binary download; test jobs passed on their first execution. Earlier GitHub startup failures required a fresh dispatch. Initial pinned-formatter and QA source-reference failures were corrected and reviewed. An additional hosted run also completed successfully for that head, including Windows and Android.Android flake proof: the exact follow-up test bytes match a prior repair whose diagnostic reproduced a late startup GET with connection admissions unchanged at 2 → 2. A deliberate reconnect negative control failed correctly, and 134 Play/ThirdParty service/session sibling tests passed. Android runtime, Gradle definitions, and dependency pins match that prior proof; local Kotlin lint passes, and all six Android jobs in CI33857853523 passed before rebase, including Play/ThirdParty tests, Wear tests, builds, and lint. Local test execution was unavailable because this host has no SDK.
Review: fresh independent Codex autoreview found no accepted/actionable P0–P2 issues in the removal, formatter follow-up, QA metadata correction, Android test correction, or current-main conflict resolution.
Current-main integration: rebased to
0c2da1da0315665a42d66241528ba0733c5a22c8; current head isb5287705391586f47de0f446fa487dec88ff81bf. Three conflicts overlapped #137606's session setup. Resolution preserves its persisted-user replay validation, synchronous ownership/cancellation admission, cleanup ownership, and new regression cases while removing only Code Mode recovery plumbing. All 100 focused cases across eight affected files pass, including 30 interrupted-user replay cases, both continuation regressions, and transcript cleanup. The formatter, QA metadata, and Android follow-ups replay unchanged. The full local changed-file gate also passes after resolution. Fresh exact-head CI33863730356 passed after the contextual patch ID changed. The next CI run exposed a stale ClawHub QA docsRef after main removed its local publishing page in #138157. A one-line metadata follow-up points to the surviving plugin-building guide; all 58 catalog tests and independent review pass, and merged-tree validation proves the missing reference is repaired without changing scenario execution or assertions.Production net -784 lines; tests/support -1073; docs -26. No configuration, database, protocol, or public SDK shape changes. Related effect-receipt work may still be useful for diagnostics and automatic whole-run replay; those broader items remain open.
Review disposition
The maintainer explicitly requested complete removal of the recovery policy and accepts the documented return to ordinary continuation after partial failures. This resolves the intentional-behavior merge-risk item in the September 4 ClawSweeper review; ordinary permissions and automatic whole-run replay protection remain.
The stored-data migration flag is not applicable. The deleted journal was a process-local WeakMap; repair authority used WeakSets, and recovery state was allocated for each run by
createEmbeddedRunTerminalRetryState. Parked cells also live in the process-localactiveRunsMap. No database schema, stored record representation, persistence codec, configuration key, or public receipt shape changes, so there is nothing to migrate or backfill. The existing transcript/lifecycle path remains the owner of recorded tool outcomes.Named follow-up from the expanded CI run:
test/scripts/direct-run-entrypoints.test.tshit an unrelated Windows subprocess close/drain timeout after producing its expected output. Its production/test owners are unchanged, and the responsible handle is not yet established; preserve the drainage contract while investigating that flake.Named follow-up from the ClawHub documentation move: the maturity renderer indexes only local documentation, so a future regeneration can drop valid mirrored ClawHub publishing links. Make that route index aware of the canonical mirror; retain the taxonomy’s public-route meaning.
Supplemental hosted fallback33865109539 observed an unrelated mocked-Gateway UI assertion: copied plain-HTTP outbox state remained
waiting-reconnectinstead ofunconfirmed. The PR changes no UI files and this fixture uses a synthetic WebSocket without an agent/model/tool executor. Record follow-up Stabilize copied-tab plain-HTTP outbox adoption proof and asset-route cleanup; lazy-module socket errors in the log do not establish the root cause. The fallback is being stopped after all118 execution jobs in the primary exact-head run passed; its failed UI job is not counted as passing proof.