Skip to content

fix: unblock sessions after force-clearing stalled startup - #139265

Merged
obviyus merged 2 commits into
openclaw:mainfrom
johan-eilertsen:codex/preflight-turn-recovery
Sep 5, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
johan-eilertsen:codex/preflight-turn-recovery

Conversation

@johan-eilertsen

@johan-eilertsen johan-eilertsen commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #139242.

Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR.

What Problem This Solves

Fixes an issue where users cannot get another reply after force-clearing a turn stalled in sandbox startup, before its backend run handle is registered.

Why This Change Was Made

Bind the existing exact-claim settlement to the reply operation immediately after local admission. Keep its assertion in the admitted execution lane so abandoned startup and late results cannot execute under or release a replacement claim. Fresh child admission gets its own settlement context.

User Impact

The next message can run after recovery. The abandoned turn cannot deliver a late answer or release its successor's claim. Existing registered-handle cleanup remains available.

Evidence

Verified current-main baseline 676845210acb1d5eb8667ae6d0811a8e7b6f0f2b and product candidate a818086565a03cf767b816038574b8573ea66855 through isolated, built Gateways:

Observation Main Candidate
First sandbox startup held after durable claim, before backend handle Observed Observed
Force-clear result aborted=false drained=false forceCleared=true Same
Old claim after force-clear Still held Released
Next message through chat.send Active-turn-claim error; no answer New claim; exactly one answer
Old startup released while successor owns claim Successor cannot acquire Successor claim unchanged; no old model request or answer

The fixture uses the shipped sandbox plugin interface and real SSH workspace preparation. Recovery calls the shipped abortAndDrainAgentHarnessRun interface used by the production recovery owner. A deterministic QA provider holds the successor response while the old startup is released. Admission, queues, SQLite claims, runtime execution, and Gateway delivery are real; no claim-store writes or restart substitute for recovery. This is isolated Gateway proof, not authenticated Telegram or native Codex-provider proof.

Controls passed: normal completion; registered backend recovery and exact release; another session's claim and answer preserved; non-forced recovery leaves an unsettled startup claim intact. The registered product control drained cooperatively; existing focused tests cover the noncooperative force-clear branch.

  • Independent source-blind validation passed all 10 prewritten behavior clauses, including the old run's lifecycle generation and exactly one successful release per claim.
  • Fresh AutoReview found no actionable P0/P1 issues.
  • The added regression module on unchanged baseline production failed 6 cases and passed 4; the same module passes on the candidate.
  • 40 focused owner tests passed across worker-turn-launcher.test.ts and worker-turn-launcher.claim-recovery.test.ts.
  • Both QA runtime builds passed; all changed files passed pinned formatting and git diff --check.
  • The earlier test timeout came from missing test setup: tools were enabled without a prepared runtime plan, causing cold real-provider loading. This PR adopts the existing reviewed two-line fixture correction. All three outcomes pass with unchanged assertions and timeouts; focused formatting and review pass. No check is bypassed.
  • Current head 94f48f09cb3a664f9e3b81d0d4ec4c124e463fb8 adds only that test correction to the tested product candidate. Runtime, build, dependency, and provider-fixture inputs are unchanged, so the original builds and all 10 acceptance clauses retain their actual tested identities. Fresh checks and review run on the new head.

Production +50/−11 (net +39), tests +271: this extends the existing settlement owner rather than adding a new recovery mechanism or configuration. Separate follow-ups: direct CLI pre-backend claim recovery remains a pre-existing sibling gap; sandbox subprocess cancellation remains outside this repair.

AI-assisted implementation and verification.

@clawsweeper

clawsweeper Bot commented Sep 5, 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.

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 3:57 PM ET / 19:57 UTC.

ClawSweeper review

What this changes

Releases stalled startup’s session claim when its reply is force-cleared, rejects late continuations, isolates new admissions from inherited claims, and supplies the prepared plan for a Codex test.

Merge readiness

✅ Ready for maintainer review

This remains a useful repair for a current-main defect. No blocking findings remain, and the supplied Gateway recovery evidence supports the unchanged production candidate.

Priority: P1
Reviewed head: 94f48f09cb3a664f9e3b81d0d4ec4c124e463fb8

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with meaningful regression coverage and production-path recovery evidence; no blocking defect found.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured before/after Gateway observations exercise real admission, SQLite claim ownership, SSH startup, recovery, and chat.send with a deterministic provider. They show successor delivery and rejection of stale startup without disturbing another session; the current head changes only the test fixture.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured before/after Gateway observations exercise real admission, SQLite claim ownership, SSH startup, recovery, and chat.send with a deterministic provider. They show successor delivery and rejection of stale startup without disturbing another session; the current head changes only the test fixture.
Evidence reviewed 10 items Early settlement binding: Local admission captures the placement owner's existing settlement closure, registers it with the exact reply operation, and checks claim validity before admission callbacks, before work, and after its result.
Canonical claim owner and final effect: executeLocalTurn captures a fresh claim token; settlement closes its assertion and releases only that claim. The existing placement store revalidates identity inside releaseTurn. Reply clearing starts successor barriers before waking successors.
Caller and sibling boundaries: The lane captures its own admitted assertion and checks it before creating attempt controls. Plugin sandbox preparation precedes that check in run-attempt-dispatch.ts. Built-in startup retains reply-signal cancellation; remote worker execution retains its separate owner. Direct CLI pre-backend recovery and sandbox subprocess cancellation are explicitly recorded as separate follow-ups in the PR body.
Findings None None.
Security None None.

How this fits together

Session admission reserves a session before sandbox startup and model execution. Recovery must release that reservation while preventing abandoned work from interfering with the next reply.

flowchart TD
  A[Incoming message] --> B[Session claim admission]
  B --> C[Sandbox startup]
  C --> D[Model execution and reply]
  B --> E[Reply recovery barrier]
  E --> F[Release exact old claim]
  F --> A
  F --> G[Reject abandoned continuation]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +39, Tests +271. Total +310 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 50 11 +39
Tests 2 271 0 +271
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 321 11 +310

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +39; tests net +271 Growth connects the existing settlement owner to pre-backend recovery and fences continuations; it adds no parallel recovery mechanism or configuration.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #139242
Summary: This PR implements the paired startup-claim recovery report; subprocess cancellation is distinct.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep settlement in the existing claim owner and attach it before startup; the added wiring is justified because backend registration cannot protect the earlier interval.

Do we have a high-confidence way to reproduce the issue?

Yes: hold startup after claim acquisition but before backend registration, force-clear, then send another message. Current source exposes the gap, and the supplied baseline Gateway run demonstrates it; this reviewer did not execute it.

Is this the best way to solve the issue?

Yes: the repair extends the existing exact-claim lifecycle at admission. Backend-only cleanup starts too late, while session-wide claim clearing could release a successor.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 6b1314938d6d.

Labels

Label justifications:

  • P1: A reported active conversation cannot accept another turn after recovery leaves its startup claim held.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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 before/after Gateway observations exercise real admission, SQLite claim ownership, SSH startup, recovery, and chat.send with a deterministic provider. They show successor delivery and rejection of stale startup without disturbing another session; the current head changes only the test fixture.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured before/after Gateway observations exercise real admission, SQLite claim ownership, SSH startup, recovery, and chat.send with a deterministic provider. They show successor delivery and rejection of stale startup without disturbing another session; the current head changes only the test fixture.

Evidence

What I checked:

  • Early settlement binding: Local admission captures the placement owner's existing settlement closure, registers it with the exact reply operation, and checks claim validity before admission callbacks, before work, and after its result. (src/agents/session-placement-admission.ts:109, 94f48f09cb3a)
  • Canonical claim owner and final effect: executeLocalTurn captures a fresh claim token; settlement closes its assertion and releases only that claim. The existing placement store revalidates identity inside releaseTurn. Reply clearing starts successor barriers before waking successors. (src/gateway/worker-environments/worker-turn-admission.ts:180, 94f48f09cb3a)
  • Caller and sibling boundaries: The lane captures its own admitted assertion and checks it before creating attempt controls. Plugin sandbox preparation precedes that check in run-attempt-dispatch.ts. Built-in startup retains reply-signal cancellation; remote worker execution retains its separate owner. Direct CLI pre-backend recovery and sandbox subprocess cancellation are explicitly recorded as separate follow-ups in the PR body. (src/agents/embedded-agent-runner/run/lane-controller.ts:117, 94f48f09cb3a)
  • Current main still needs the repair: Fetched main still invokes admitTurn and task without registering early reply-owned settlement. Comparing the three production files against this main revision produces the same introduced repair, not unrelated base drift. (src/agents/session-placement-admission.ts:104, 6b1314938d6d)
  • Latest release boundary: The inspected v2026.9.1 admission code also lacks the early settlement binding; its tag resolves to the supplied release commit. (src/agents/session-placement-admission.ts:104, ad6fe23aecb9)
  • Regression coverage: The new module contains ten parameterized cases covering fresh child admission, standalone isolation, three late-continuation stages, and clearing before/during admission. It uses the production placement store and recovery owner. Existing worker-turn-launcher tests separately cover normal release, reused run IDs, stale finalizers, and registered-handle recovery. The supplied body reports six new cases failing on baseline and all ten passing on the candidate; tests were not executed during this read-only review. (src/gateway/worker-environments/worker-turn-launcher.claim-recovery.test.ts:47, 94f48f09cb3a)

Likely related people:

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

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 (2 earlier review cycles)
  • reviewed 2026-09-05T18:17:13.639Z sha a818086 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-05T19:45:54.495Z sha a818086 :: needs maintainer review before merge. :: none

@obviyus obviyus self-assigned this Sep 5, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 Sep 5, 2026
@obviyus

obviyus commented Sep 5, 2026 •

Copy link
Copy Markdown
Collaborator

Thanks @johan-eilertsen. Landed as 1321b60e.

Verification complete for 94f48f09.

  • Isolated Gateway proof reproduces the failure on main, then confirms exact old-claim release, one successor answer, and rejection of the late old continuation. All 10 independent behavior clauses pass. Product proof retains its original a8180865 build identity; the final head adds only the reviewed test-fixture correction.
  • node scripts/run-vitest.mjs src/gateway/worker-environments/worker-turn-launcher.claim-recovery.test.ts src/gateway/worker-environments/worker-turn-launcher.test.ts: 40 passed. The added regression module fails 6 cases on original production code.
  • node scripts/run-vitest.mjs extensions/codex/src/app-server/run-attempt.agent-end-context.test.ts: 3 passed. Both QA runtime builds, pinned formatting, scoped lint, AutoReview, and the exact-head local ClawSweeper review pass.
  • Required CI run 33988337281, attempt 3, is green. A dependency download reset and an ACP cleanup timing check each received one separately justified targeted retry. No checks, assertions, or timeouts were bypassed or weakened. The precise ACP latency cause remains unconfirmed.

The guarded merge and resulting source were verified. Contributor credit is preserved.

@obviyus
obviyus merged commit 1321b60 into openclaw:main Sep 5, 2026
516 of 523 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
…139265)

Release the exact admitted claim when recovery force-clears a turn stalled before backend registration. Fence the old continuation so the next message can answer without losing its replacement claim.

Use the existing prepared runtime-plan fixture in the context-propagation test to avoid unintended real-provider loading while retaining its assertions and timeout.

Closes openclaw#139242.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

[Bug]: Force-clearing stalled startup leaves the session unable to accept messages

2 participants