Skip to content

fix(agents): preserve subagent work across gateway restarts - #169144

Merged
steipete merged 4 commits into
mainfrom
steipete/perf-micro-subagent-resume-after-restart-20260919
Oct 11, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/perf-micro-subagent-resume-after-restart-20260919

Conversation

@steipete

@steipete steipete commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes native subagent work being stranded when a Gateway restart interrupts a turn, including quiet children whose parent has already finished.

User Impact

Interrupted children retain their history and privately hand unfinished work back to their original parent once. Successful quiet children remain quiet. The parent reconciles saved history and uncertain tool effects before continuing; recovery does not blindly replay child commands.

Cancellation and reset still revoke the continuation. A cancelled turn's remaining cleanup lease cannot make the next Gateway restart resume it again. No schema change, new user setting, or operator migration is required. Ambiguous historical failures are not reclassified from their error text.

Why This Change Was Made

Restart drain cancels passive agent.wait observations. The shared wait helper discarded the structured retryable refusal, and a retiring lifecycle owner could replace it with an untyped error. The registry then invented a child failure and began deletion before recording the genuine restart interruption. Preserve explicit retryable UNAVAILABLE errors at these boundaries; actual terminal errors remain terminal.

The existing requester-settle owner now carries quiet interrupted children privately, with the captured parent identity, durable batch receipt, and current-owner checks. Nested parent recovery recognizes that custody. Interrupted children keep the history needed for reconciliation even when normal completion would delete it.

The real cancellation regression also exposed a shutdown ownership bug: acquired cleanup admissions were treated as unfinished work after their run had been cancelled. Restart capture now consults the execution owner's existing terminal and abort facts, including after handoff and immediately before marking. It excludes settled explicit cancellation while retaining successful or timed-out executions whose final delivery is still pending, as well as typed restart interruptions.

Production LOC: +84. The growth implements missing continuation and cancellation contracts using existing owners; it adds no dispatcher, retry store, cache, schema, or configuration surface.

Evidence

  • Pre-fix real Gateway comparison: no parent continuation; the same original regression fails. Structured wait refusal regressions fail on the old production code too.
  • Earlier AWS Crabbox cbx_f500a39cd475: 397 focused/sibling tests passed (83.29 seconds wrapper time); export collision guard passed; 143 closure/test-plan guards passed (109.02 seconds).
  • Hetzner Crabbox cbx_88437d85909a, Node 24.19.0 / pnpm 12.9.0: final owner/startup/restart suites 223 passed, 324.17 seconds wrapper time. node scripts/run-vitest.mjs ran the session admission suites and main-session startup, restart, and marking suites.
  • On that same lease, node scripts/run-vitest.mjs --config test/vitest/vitest.e2e.config.ts test/gateway-subagent-restart.e2e.test.ts: 3 passed, 134.000 seconds of test execution. Each case uses real sessions_spawn, a managed restart intent plus SIGTERM, and another restart after continuation settlement. The synthetic provider counts final serialized requests.
Case Recovery provider requests Requests after revocation Original-parent replay on next boot
Authorized continuation 1 — 0
Reset during authorized request 1 before reset 0 0
Cancellation before dispatch 0 0 0
  • The same cancellation flow failed before the cleanup-ownership fix: the next shutdown marked an already cancelled parent as interrupted and startup issued its original prompt again.

  • node scripts/check-changed.mjs --base HEAD^: all preliminary guards, production types, core-test types, and root tooling types passed. It stopped on the unchanged Windows fixture calling removed stopGatewayProcess; current main fixes that in 2695b46dd136. The remaining root E2E/other type partitions passed when run directly through the same native shard owner.

  • Final changed-file lint plan, including the new sibling test: passed, zero warnings/errors. Export-name collision guard: passed. Closure and CI test-plan guards: 143 passed, 115.46 seconds wrapper time.

  • The full-tree dead-export scan flagged an unchanged, actually used lazy subagent maintenance import. Script/production scans passed; main fixes scanner visibility in a44f088e7b98. No real consumer was removed.

  • An independently installed, unchanged base checkout reproduced the prior CI terminal-layout timeout in ui/src/e2e/chat-panel-layout.e2e.test.ts. This PR changes no UI source.

  • Exact-head CI caught a missing channel reply caller: its typed restart reason lives on the reply operation, not the upstream signal. The caller now supplies that reason. Hetzner cbx_3ef81015fe4f: the previously failing server-plugins.test.ts and all seven reply-admission sibling suites passed in 139.78 seconds across three Vitest shards; core production types and focused lint passed.

  • The final-delivery correction passed 143 focused tests in 167.12 seconds on Hetzner cbx_0fd6d568d268, including the actual RPC queued-reply restart regression, ACP completion, plugin reply ownership, admission, and restart-marking suites.

  • Final-candidate real managed restart proof on the same Hetzner lease: 3 passed, 152.498 seconds test execution (553.40 seconds including a clean build and test preparation). It preserves exactly one private continuation, zero post-revocation requests, and zero original-parent replays on another restart.

  • Core production types and focused lint passed on that final candidate. The separate ACP completion file also passed all 13 cases on unchanged CI main parent d789eb10a28293751d980bf23406d6597e42a236 (121.99 seconds wrapper time). The earlier missing-start-frame failure did not reproduce on either tree; source inspection identifies a possible abort-versus-start-publication fixture race in unchanged code. This PR does not claim to fix it.

  • Final changed-file gate on Hetzner cbx_5a36f75315a0: node scripts/check-changed.mjs -- docs/gateway/restart-recovery.md src/sessions/session-lifecycle-admission.ts src/sessions/session-lifecycle-admission.pending.test.ts src/agents/main-session-recovery/main-session-restart-recovery-marking.test.ts. All preliminary guards, formatting, core production types, and all 28 core-test type graphs passed (1,644.75 seconds for the core-test graphs). The gate then stopped on the same inherited full-tree dead-export scanner false positive for loadSubagentMaintenanceCandidatesInDatabase, fixed by main commit a44f088e7b98. Production and script export scans passed. Focused lint was already green on the identical candidate.

  • Independent review: final candidate, channel reply correction, and final-delivery correction are clean through P2, including the original-parent replay assertion, first-abort precedence, and pending delivery custody.

  • Final exact-head CI: run 38172242196 passed on ec4cf17a098f7a5bb2b5c435b0bdc22bca90dcc2, including the aggregate CI/security gate. Fresh exact-head review found no actionable findings and rated proof/patch quality 5/6.

All runtime proof uses synthetic provider responses, isolated state, and owned Gateway processes. No production Gateway was touched.

@clawsweeper

clawsweeper Bot commented Oct 11, 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 gateway Gateway runtime agents Agent runtime and tooling size: L labels Oct 11, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR preserves interrupted subagent history and parent continuation while preventing cancelled work from restarting.

Example: A child spawned with expectsCompletionMessage=false and cleanup="delete" is interrupted after its parent finishes.

  • Before: The child can lose its history and leave its assignment stranded.
  • After: Its history remains available and one private continuation returns unfinished work to the original parent.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused owner-level repair with shipped-entry-point recovery and revocation evidence; both earlier correctness findings are resolved.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The supplied final-candidate report exercises built Gateway processes on isolated Linux state through authenticated RPCs, real provider HTTP transport, managed restart, and subsequent restart: one authorized private continuation, zero cancellation-before-dispatch requests, and zero additional requests after reset or settlement.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Delegated assignments can stop silently across Gateway restarts, and cancelled work can otherwise be rearmed by retained cleanup custody.
Reason: The maintainer-owned direction repairs task completion while explicitly preserving cancellation, reset, privacy, and parent reconciliation.

Merge readiness

✅ Ready for maintainer review

Both prior findings are resolved, and no actionable defect remains in the reviewed patch; exact-head CI is still running.

Priority: P1
Reviewed head: ec4cf17a098f7a5bb2b5c435b0bdc22bca90dcc2

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway shutdown captures session admissions, startup reconciles persisted subagent runs, and requester settlement delivers unfinished work to the current parent owner.

flowchart TD
  A[Gateway restart] --> B[Session admission capture]
  B --> C[Durable recovery markers]
  C --> D[Subagent reconciliation]
  D --> E[Requester settlement]
  E --> F[Original parent continuation]
  G[Cancellation or reset] --> B
  G --> E
Loading

Technical review

Best possible solution:

Preserve parent-owned recovery and pending delivery custody through the existing admission and requester-settlement owners.

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

The base source loses structured retryable wait refusals and excludes quiet children from required settlement; the supplied process comparison reports the original scenario failing before repair.

Is this the best way to solve the issue?

The repair addresses error classification, retained history, continuation ownership, and cancellation at their existing owners without adding a competing replay mechanism.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8524e7f1cbe2.

Provenance checked

  • Parent-owned restart recovery and interrupted-child retention changes intended behavior with a stated reason (18f1c11: Remove automatic child relaunch and make the parent reconcile retained history and finish the request.)
  • Nested requester continuation custody keeps the original intent (915a974: Prevent orphan reconciliation from replacing an already-owned saved continuation with a false interruption failure.)
  • Requester completion batch selection changes intended behavior with a stated reason (9476fe5: Serialize batch decisions so sibling completions preserve the requester's wake.)
  • Gateway lifecycle wait errors keeps the original intent (3d926b2: Use instance-bound in-process routing while retaining current-Gateway checks and validated execution authority.)
  • Admission handoff and terminal settlement keeps the original intent (a2a9ff2: Distinguish committed execution outcomes from retained cleanup so session operations can proceed correctly after final publication.)
  • Cold-restart live expectations changes intended behavior with a stated reason (b49b988: Align release proof with parent-owned recovery after automatic child replay was retired.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Prior final-delivery finding resolved: The revised predicate retains acquired admissions for completed execution, timeout, and restart interruption; settled explicit cancellation is excluded during both capture and subsequent owner revalidation. (src/sessions/session-lifecycle-admission.ts:360, ec4cf17a098f)
  • Prior channel-caller finding resolved: Reply admission supplies operation.abortSignal.reason, and adopted agent admissions replace their terminal-state and abort-reason callbacks with the current execution owner's callbacks. (src/auto-reply/reply/reply-turn-admission.ts:253, ec4cf17a098f)
  • Final-effect recovery and revocation proof: The maintainer's final-candidate execution report records three passing real Gateway process scenarios. Inspection confirms actual sessions_spawn, managed process replacement, provider HTTP request counting, cancellation before dispatch, reset during an authorized request, and another restart after settlement. (test/gateway-subagent-restart.e2e.test.ts:394, ec4cf17a098f)
  • Scoped Gateway proof requirement covered: The process scenario creates agent:main:quiet-child-restart through public sessions.create and immediately executes chat.send against it, covering explicit non-main session publication and subsequent use. (test/gateway-subagent-restart.e2e.test.ts:394, ec4cf17a098f)
  • Existing storage representation remains compatible: The latest stable codec already reads and writes the parentCompletion wrapper used by private completion records. This patch introduces no schema or serialized field, and repeated process restarts exercise persistence and consumption of the existing representation. Missing local historical objects were bypassed with a read-only GitHub source read. (src/agents/subagents/registry/subagent-registry.store.codec.ts:43, e178c39e9aae)
  • Recovery direction and retention tradeoff accepted: The maintainer-authored body explicitly chooses retained interrupted-child history, private original-parent continuation, and cancellation/reset revocation without automatic child-command replay. Public docs: docs/gateway/restart-recovery.md. (docs/gateway/restart-recovery.md:877, ec4cf17a098f)

Likely related people:

  • Peter Steinberger: Raw commit 2dd328a adds src/agents/subagents/announce/subagent-announce.requester-settle-wake.ts:391 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2dd328a2a0cc; files: src/agents/subagents/announce/subagent-announce.requester-settle-wake.ts)
  • Josh Avant: Raw commit 4b7f193 adds src/gateway/server-recovery-runtime-context.ts:11 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 4b7f193c9d57; files: src/gateway/server-recovery-runtime-context.ts)
  • RoboClaw: Raw commit 9476fe5 adds src/agents/subagents/announce/subagent-announce.requester-settle-wake.ts:406 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 9476fe514b8b; files: src/agents/subagents/announce/subagent-announce.requester-settle-wake.ts)

PR surface

Source +84, Tests +826, Docs +11. Total +921 across 20 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 11 103 19 +84
Tests 8 848 22 +826
Docs 1 12 1 +11
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 20 963 42 +921

Review metrics

Metric Value Why it matters
Production versus test growth Production +103/-19; tests +848/-22 The net 84 production lines extend existing owners; most test growth supplies process-restart and final-effect revocation coverage.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Gateway restarts can strand delegated work or lose pending final-delivery recovery, breaking active agent workflows.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (5 earlier review cycles)
  • reviewed 2026-10-11T14:07:51.453Z sha 9050625 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-11T14:15:05.799Z sha 9050625 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-11T15:04:44.197Z sha 9f31eb4 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-11T18:17:59.302Z sha a97370f :: needs changes before merge. :: [P2] Carry the channel reply owner's abort reason into restart capture
  • reviewed 2026-10-11T19:03:51.634Z sha 7b74bd9 :: needs changes before merge. :: [P1] Keep replies awaiting final delivery eligible for restart recovery

Reviewed October 11, 2026, 4:32 PM ET / 20:32 UTC (Revision 6).

@steipete
steipete marked this pull request as ready for review October 11, 2026 14:08
@steipete
steipete force-pushed the steipete/perf-micro-subagent-resume-after-restart-20260919 branch from 9050625 to 9f31eb4 Compare October 11, 2026 14:51
Carry live terminal and abort facts through session admission handoffs so retained cleanup cannot restart cancelled work. Extend real Gateway recovery proof to cover reset, cancellation before provider dispatch, and repeated restarts.
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The prior revocation-proof gap is covered on head a97370fb65414b094a79968fcb94eb58a4a3041f by the real Gateway process test in test/gateway-subagent-restart.e2e.test.ts:

  • Authorized quiet-child recovery sends one private continuation, retains child history, and does not replay on the next restart.
  • chat.abort before provider dispatch produces zero recovery provider requests, including after the next restart.
  • sessions.reset while one authorized provider request is pending produces zero additional requests after reset or the next restart.
  • Every case also asserts exactly the two original parent requests, so replay of the original prompt cannot hide behind the private-continuation counter.

The proof caught and fixed an actual cancellation/restart bug: a terminal cleanup admission could otherwise re-arm the stopped parent. The admission owner now carries the current consumer's terminal and first-abort facts through handoff, with live revalidation at the restart mark. Typed restart interruptions still recover.

Hetzner Crabbox cbx_88437d85909a: all three process scenarios passed in 134.000 seconds; 223 owner/startup/restart tests and 143 closure/test-plan tests passed. Final lint has zero warnings/errors. The PR body records the unrelated baseline type/dead-export issues and their existing main fixes. Independent review of the final behavior is clean through P2.

@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 11, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Fixed the missing channel reply caller in 7b74bd963c249de4eee05f9d49fecf1b48be47e3: admitReplyTurn now carries operation.abortSignal.reason into the existing admission snapshot, alongside its terminal-state callback.

The previously failing src/gateway/server-plugins.test.ts and all seven reply-turn-admission sibling suites pass on Hetzner cbx_3ef81015fe4f (three Vitest shards, 139.78 seconds). Core production types and focused lint pass, and independent review of the caller fix is clean. The prior real Gateway revocation proof remains unchanged; the body records it and the inherited baseline exceptions.

@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 11, 2026
Keep completed executions with an outstanding delivery admission eligible
for restart recovery. Only settled explicit user cancellation revokes that
custody; timeout and restart interruption retain it until release.

Preserve the regression coverage for cancellation after recovery planning
and adopted admissions, including timeout and pending final delivery.
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The pending-final-delivery finding is fixed at the admission owner. A finished execution that still owns final delivery remains restart-recoverable; only settled explicit cancellation ends that custody. Timeout and restart interruption retain recovery, and the live check immediately before marking still rejects released, cancelled, or replaced owners.

Hetzner Crabbox cbx_0fd6d568d268 ran the final candidate with the local patch: 143 focused tests passed in 167.12s, including the actual RPC queued-reply restart regression, plugin reply ownership, admission handoff, and restart marking. Core types and focused lint passed. The real managed restart E2E passed all 3 cases in 152.498s test time (553.40s including a clean build): exactly one authorized private continuation, zero requests after revocation, and zero original-parent replays on another restart. Independent review of the correction is clean through P2.

The separate ACP lifecycle-start assertion passed on both candidate and unchanged CI main parent d789eb10a28293751d980bf23406d6597e42a236 (13 cases, 121.99s wrapper time on the baseline). Its earlier CI failure did not reproduce. Source inspection found an unawaited start-publication race in unchanged test/event code; this PR does not claim to repair that intermittent failure.

@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 11, 2026
@steipete
steipete merged commit 187a884 into main Oct 11, 2026
145 of 149 checks passed
@steipete
steipete deleted the steipete/perf-micro-subagent-resume-after-restart-20260919 branch October 11, 2026 20:43
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
…#169144)

* fix(agents): preserve subagent work across gateway restarts

* fix(sessions): preserve cancellation across gateway restarts

Carry live terminal and abort facts through session admission handoffs so retained cleanup cannot restart cancelled work. Extend real Gateway recovery proof to cover reset, cancellation before provider dispatch, and repeated restarts.

* fix(gateway): retain channel reply restart ownership

* fix(sessions): retain restart custody until final delivery

Keep completed executions with an outstanding delivery admission eligible
for restart recovery. Only settled explicit user cancellation revokes that
custody; timeout and restart interruption retain it until release.

Preserve the regression coverage for cancellation after recovery planning
and adopted admissions, including timeout and pending final delivery.
RomneyDa pushed a commit that referenced this pull request Oct 13, 2026
… (2026.10.5 backport)

Restart drain cancels passive agent.wait observations; the wait helper dropped
the structured retryable UNAVAILABLE refusal, so the registry invented a child
failure and began deletion before recording the restart interruption. Quiet
interrupted children are now handed privately back to their original parent,
keep their history, and cancelled turns' cleanup leases no longer make them
restart-recovery candidates.

Backport adaptation (conflicts only, no behavior dropped):
- src/agents/run-wait.ts: the branch inlined error normalization in
  waitForAgentRun via isRecoverableAgentWaitError; replaced it with main's
  normalizeAgentWaitError(cause), which also honors typed UNAVAILABLE.
- src/sessions/session-lifecycle-admission.ts: kept the branch's
  isSessionWorkAdmissionActive export and its lifecycleGeneration fences on
  captured owners; isRestartRecoverableAdmission replaces only the bare
  phase === "acquired" checks in those two restart-capture sites.
- session-lifecycle-admission.pending.test.ts: took only the new
  restart-capture regression; dropped two neighboring main-only tests for
  captureSessionWorkRunInterruptions, which the branch does not have.

Extracted-from: 187a884
Co-authored-by: Peter Steinberger <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 17, 2026
The native subagent restart live proof SIGKILLs the Gateway three times in
about two minutes. The third unclean boot trips the documented restart-loop
breaker (3 unclean boots within 5 minutes, #166238), which pauses restart
settlement, including interrupted subagent recovery (#166846), until the
unclean window drains. The orphan assertion added with the #169144 backport
only waited 30 seconds, so the nonannouncing child was still `running`.

Wait up to 360 seconds for the orphan settlement so the proof covers the
breaker pause and the automatic resume after its window. Assertions are
unchanged. 2026.10.4 passed because it predates the breaker pause, startup
subagent reconciliation, and this assertion.

Deterministic proof: the quiet-child e2e twin with SIGKILL restarts and an
exec-blocked child passes with one prior kill; with two warm-up kills it logs
"restart-loop breaker tripped" and the parent continuation never arrives
within 60 seconds; with a 400-second wait it settles and passes (338s).
RomneyDa added a commit that referenced this pull request Oct 17, 2026
…sters (#175278)

The #169144 backport converts a non-announcing child interrupted by a
Gateway restart into a private parent continuation only when the captured
requester has both a session id and a lifecycle revision. Sessions created
implicitly by the `agent` RPC (and other paths that never patch a new
session) carry no lifecycle revision, so the orphan settled terminal with
no completionTarget or requester settle wake and the parent never received
the "Reconcile every listed unfinished child" turn.

Every downstream requester identity check already compares the captured
revision by equality (absent matches absent, and a reset assigns a new
revision), and private spawn only requires a requester session id. Apply
the same requirement here.

The native live subagent restart proof starts its parents through `agent`,
which is why its parent-handoff assertion timed out; the crash-loop breaker
only delayed settlement. A quiet-child e2e twin started via `agent` failed
with and without the breaker before this change and receives the parent
reconcile turn within a second of settlement after it.
RomneyDa added a commit that referenced this pull request Oct 17, 2026
…sters (#175278)

The #169144 backport converts a non-announcing child interrupted by a
Gateway restart into a private parent continuation only when the captured
requester has both a session id and a lifecycle revision. Sessions created
implicitly by the `agent` RPC (and other paths that never patch a new
session) carry no lifecycle revision, so the orphan settled terminal with
no completionTarget or requester settle wake and the parent never received
the "Reconcile every listed unfinished child" turn.

Every downstream requester identity check already compares the captured
revision by equality (absent matches absent, and a reset assigns a new
revision), and private spawn only requires a requester session id. Apply
the same requirement here.

The native live subagent restart proof starts its parents through `agent`,
which is why its parent-handoff assertion timed out; the crash-loop breaker
only delayed settlement. A quiet-child e2e twin started via `agent` failed
with and without the breaker before this change and receives the parent
reconcile turn within a second of settlement after it.

(cherry picked from commit 8d4591a)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
…sters (openclaw#175278)

The openclaw#169144 backport converts a non-announcing child interrupted by a
Gateway restart into a private parent continuation only when the captured
requester has both a session id and a lifecycle revision. Sessions created
implicitly by the `agent` RPC (and other paths that never patch a new
session) carry no lifecycle revision, so the orphan settled terminal with
no completionTarget or requester settle wake and the parent never received
the "Reconcile every listed unfinished child" turn.

Every downstream requester identity check already compares the captured
revision by equality (absent matches absent, and a reset assigns a new
revision), and private spawn only requires a requester session id. Apply
the same requirement here.

The native live subagent restart proof starts its parents through `agent`,
which is why its parent-handoff assertion timed out; the crash-loop breaker
only delayed settlement. A quiet-child e2e twin started via `agent` failed
with and without the breaker before this change and receives the parent
reconcile turn within a second of settlement after it.
yozakura-ava pushed a commit to yozakura-ava/openclaw that referenced this pull request Oct 19, 2026
…#169144)

* fix(agents): preserve subagent work across gateway restarts

* fix(sessions): preserve cancellation across gateway restarts

Carry live terminal and abort facts through session admission handoffs so retained cleanup cannot restart cancelled work. Extend real Gateway recovery proof to cover reset, cancellation before provider dispatch, and repeated restarts.

* fix(gateway): retain channel reply restart ownership

* fix(sessions): retain restart custody until final delivery

Keep completed executions with an outstanding delivery admission eligible
for restart recovery. Only settled explicit user cancellation revokes that
custody; timeout and restart interruption retain it until release.

Preserve the regression coverage for cancellation after recovery planning
and adopted admissions, including timeout and pending final delivery.

(cherry picked from commit 187a884)
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 20, 2026
First-parent upstream e63e209..0b0c2f2 (93 commits, including
openclaw#169144 subagent work across gateway restarts, openclaw#169251 worker write
transaction overhead, openclaw#169306 question-answer custody, openclaw#169305 fallback
ordering, openclaw#169339 owner-state rechecks, openclaw#169235/openclaw#168887 Solid UI ports).
Stops before openclaw#169315 (fp#248, agent schema), which is step 59 on its own.

Conflicts:
- embedded-agent-runner/run/payloads.ts: upstream gates the
  assistant-texts branch on !assistantForPayload (an empty canonical
  terminal stays authoritative); kept our per-hop raw-answer split for
  earlier continuation signals ahead of it.
- session-reset-cleanup.test.ts: upstream's retainEmbeddedSessionPromptState
  disposable; kept our async clearSessionResetRuntimeState call.
- plugin-sdk-surface-report.mts: upstream 3674/2135, ours +11/+4.
- config-baseline counts/sha256 and worker-access inventory regenerated
  on the merged tree (core +17 fork config entries, as before).

Auto-merged files that carry continuation overlay (19, incl.
attempt-execution, agent-runner-fallback-candidate, session.ts,
status-message, stream/update handlers) keep the overlay byte-for-byte.

Refs #1475

Co-Authored-By: Claude Opus 5.5 <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 20, 2026
The native subagent restart live proof SIGKILLs the Gateway three times in
about two minutes. The third unclean boot trips the documented restart-loop
breaker (3 unclean boots within 5 minutes, #166238), which pauses restart
settlement, including interrupted subagent recovery (#166846), until the
unclean window drains. The orphan assertion added with the #169144 backport
only waited 30 seconds, so the nonannouncing child was still `running`.

Wait up to 360 seconds for the orphan settlement so the proof covers the
breaker pause and the automatic resume after its window. Assertions are
unchanged. 2026.10.4 passed because it predates the breaker pause, startup
subagent reconciliation, and this assertion.

Deterministic proof: the quiet-child e2e twin with SIGKILL restarts and an
exec-blocked child passes with one prior kill; with two warm-up kills it logs
"restart-loop breaker tripped" and the parent continuation never arrives
within 60 seconds; with a 400-second wait it settles and passes (338s).

(cherry picked from commit 1a4c2a0)
RomneyDa added a commit that referenced this pull request Oct 20, 2026
…7319)

* fix(test): treat the env-gated Agents API live proof as optional shard evidence

test/gateway-agentsapi.live.test.ts (new since 2026.10.4) skips its only case
unless OPENCLAW_LIVE_AGENTS_API=1, which the native live test-harness shard
never sets, so the shard's no-passing-assertions guard failed it on every
2026.10.5 candidate once the other harness tests went green. Register it in
the existing whole-file opt-in map like the other env-gated live proofs.

(cherry picked from commit 761ef64)

* fix(test): decode the Codex CLI JSON error after plugin uninstall

The live Codex npm plugin lane matched the expected post-uninstall error
against raw --json stdout, where quotes are escaped, so the correct
owner-plugin-not-activatable error never matched. Decode the canonical CLI
error message first, as the 2026.10.4 release line does (a9fd56d).

(cherry picked from commit e8772a9)

* fix(test): scope CLI announcement barrier to parent probe

(cherry picked from commit d5c0db7)
(cherry picked from commit a48d4a8)

* test(live): wait out the crash-loop breaker before the orphan settles

The native subagent restart live proof SIGKILLs the Gateway three times in
about two minutes. The third unclean boot trips the documented restart-loop
breaker (3 unclean boots within 5 minutes, #166238), which pauses restart
settlement, including interrupted subagent recovery (#166846), until the
unclean window drains. The orphan assertion added with the #169144 backport
only waited 30 seconds, so the nonannouncing child was still `running`.

Wait up to 360 seconds for the orphan settlement so the proof covers the
breaker pause and the automatic resume after its window. Assertions are
unchanged. 2026.10.4 passed because it predates the breaker pause, startup
subagent reconciliation, and this assertion.

Deterministic proof: the quiet-child e2e twin with SIGKILL restarts and an
exec-blocked child passes with one prior kill; with two warm-up kills it logs
"restart-loop breaker tripped" and the parent continuation never arrives
within 60 seconds; with a 400-second wait it settles and passes (338s).

(cherry picked from commit 1a4c2a0)

* test(qa-lab): skip user-role runtime carriers in visible-child send proof

The sessions_send visible-child proof timed out on every 2026.10.5
candidate: its synthetic provider picked the latest user item that lacked
the legacy <<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>> marker as the user prompt.

Since #168546 (backport 8d66b94), OpenAI-compatible Responses
endpoints, including mock-openai, keep runtime context in a user-role
"OpenClaw runtime context:" carrier after the user turn instead of a
developer message. The fixture then read that carrier as the prompt, never
saw the "send" prompt on turn 2, answered PARENT_READY again, and the test
waited for PARENT_DONE until timeout.

Captured provider requests: v2026.10.4 sends the turn-2 carrier with role
developer; the 10.5 tip sends it with role user. Reverting a293f2e
(#168410) left the failure unchanged.

Select the prompt with the shared qa-lab isInternalRuntimeContextCarrierText
helper, which already accepts current and legacy carrier shapes.

(cherry picked from commit d3a06e7)

* test(buzz): skip real reconnect backoff in cold-start recovery

(cherry picked from commit fa2049a)

* fix(release): let the Telegram release lane finish its 25 scenarios

The isolated Telegram candidate job hit its 60-minute limit at scenario 24/25
on every 2026.10.5 candidate (about 62 minutes needed at 102-108s per packaged
Gateway start). main carries the same Telegram scenario set and job, so
raise the job budget to 90 minutes; the calling release-checks job keeps its
210-minute bound.

Also carry the 2026.10.4 release-line fixture fix for
telegram-prepared-delivery-recovery (8b78670): keep the audit receipt in
the shared Gateway workspace and create it up front so the isolated SUT can
append without EACCES. main still writes it under the private tempRoot.

(cherry picked from commit 3cb49f0, adapted to main's runner anchor)

* test(gateway): probe startup readiness on fresh connections

The deferred-fleet startup test failed twice in 2026.10.5 FRV #12 with
`fetch failed` / `read ECONNRESET`. Its Gateway shares the test process's
event loop. A /healthz or /readyz probe could reuse a keep-alive socket
that Undici still treated as live; when the request was written and a
synchronous main-thread startup stall followed, the server's idle-timer
callback ran before the poll phase read the request and destroyed the
socket with the request unread, so the kernel reset the connection.

main still probes with default keep-alive fetches. Probe with
`Connection: close`, matching existing Gateway test probes. Assertions are
unchanged.

(cherry picked from commit e3c63f2, adapted to main's probe sites)

* test(live): expect review effort for Skill Workshop background reviews in the Ultra lane

Since #161057 the Skill Workshop counts iterations per session, so Ultra probe
sessions trigger a background review after idling. The review runs under its
own skill-workshop-review: run and does not inherit the session's thinking
level, so the lane's every-request-is-max assertion failed on 2026.10.5
whenever a review reached the provider.

On main, #173889 pins review runs to thinkLevel "low" (review-run.ts), which
the OpenAI stream wrapper sends as effort "low". Expect that effort for review
runs; Ultra runs and their sessions must still be max, and independent
heartbeats stay medium.

The live file is over the line cap, so the Ultra wire effort policy moves to
a sibling helper with its observation type, and the deterministic review
cases run in the normal helper suite.

(cherry picked from commit ca15213, adapted to main's review thinking level)

* test(release): forward-port 2026.10.4-line upgrade-survivor and runtime-smoke harness fixes

Release-line harness fixes that 2026.10.1-2026.10.5 carried but main never
received:

- cron-scheduled-authority: seed the cron authority specimen through the
  published baseline's own SQLite writer (seedPublishedCronJobs) instead of a
  raw cron/jobs.json that current candidates treat as a retired pre-July
  store; drop owner fields for pre-2026.7.1 baselines
  (usesCronOwnerAtBaseline). The dispatcher passes the package root to
  seedState, and the scenario now requires a published baseline.
- bundled plugin runtime smoke: join deferred read-only update discovery via
  update.status before the package-manager child watchdog. main still defers
  install discovery (`<manager> root -g`) until after ready, so it can race
  the watchdog's no-package-manager-children check.

Skips the codex npm plugin live source-reply grep from the release commit:
main already probes dynamic-tool-source-reply.ts and dynamic-tools.ts.

(cherry picked from commit fcdf0d1, codex grep hunk dropped; cron seed
test adapted to main's executable-mode fixture writes)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
…nclaw#177319)

* fix(test): treat the env-gated Agents API live proof as optional shard evidence

test/gateway-agentsapi.live.test.ts (new since 2026.10.4) skips its only case
unless OPENCLAW_LIVE_AGENTS_API=1, which the native live test-harness shard
never sets, so the shard's no-passing-assertions guard failed it on every
2026.10.5 candidate once the other harness tests went green. Register it in
the existing whole-file opt-in map like the other env-gated live proofs.

(cherry picked from commit 761ef64)

* fix(test): decode the Codex CLI JSON error after plugin uninstall

The live Codex npm plugin lane matched the expected post-uninstall error
against raw --json stdout, where quotes are escaped, so the correct
owner-plugin-not-activatable error never matched. Decode the canonical CLI
error message first, as the 2026.10.4 release line does (a9fd56d).

(cherry picked from commit e8772a9)

* fix(test): scope CLI announcement barrier to parent probe

(cherry picked from commit d5c0db7)
(cherry picked from commit a48d4a8)

* test(live): wait out the crash-loop breaker before the orphan settles

The native subagent restart live proof SIGKILLs the Gateway three times in
about two minutes. The third unclean boot trips the documented restart-loop
breaker (3 unclean boots within 5 minutes, openclaw#166238), which pauses restart
settlement, including interrupted subagent recovery (openclaw#166846), until the
unclean window drains. The orphan assertion added with the openclaw#169144 backport
only waited 30 seconds, so the nonannouncing child was still `running`.

Wait up to 360 seconds for the orphan settlement so the proof covers the
breaker pause and the automatic resume after its window. Assertions are
unchanged. 2026.10.4 passed because it predates the breaker pause, startup
subagent reconciliation, and this assertion.

Deterministic proof: the quiet-child e2e twin with SIGKILL restarts and an
exec-blocked child passes with one prior kill; with two warm-up kills it logs
"restart-loop breaker tripped" and the parent continuation never arrives
within 60 seconds; with a 400-second wait it settles and passes (338s).

(cherry picked from commit 1a4c2a0)

* test(qa-lab): skip user-role runtime carriers in visible-child send proof

The sessions_send visible-child proof timed out on every 2026.10.5
candidate: its synthetic provider picked the latest user item that lacked
the legacy <<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>> marker as the user prompt.

Since openclaw#168546 (backport 8d66b94), OpenAI-compatible Responses
endpoints, including mock-openai, keep runtime context in a user-role
"OpenClaw runtime context:" carrier after the user turn instead of a
developer message. The fixture then read that carrier as the prompt, never
saw the "send" prompt on turn 2, answered PARENT_READY again, and the test
waited for PARENT_DONE until timeout.

Captured provider requests: v2026.10.4 sends the turn-2 carrier with role
developer; the 10.5 tip sends it with role user. Reverting a293f2e
(openclaw#168410) left the failure unchanged.

Select the prompt with the shared qa-lab isInternalRuntimeContextCarrierText
helper, which already accepts current and legacy carrier shapes.

(cherry picked from commit d3a06e7)

* test(buzz): skip real reconnect backoff in cold-start recovery

(cherry picked from commit fa2049a)

* fix(release): let the Telegram release lane finish its 25 scenarios

The isolated Telegram candidate job hit its 60-minute limit at scenario 24/25
on every 2026.10.5 candidate (about 62 minutes needed at 102-108s per packaged
Gateway start). main carries the same Telegram scenario set and job, so
raise the job budget to 90 minutes; the calling release-checks job keeps its
210-minute bound.

Also carry the 2026.10.4 release-line fixture fix for
telegram-prepared-delivery-recovery (8b78670): keep the audit receipt in
the shared Gateway workspace and create it up front so the isolated SUT can
append without EACCES. main still writes it under the private tempRoot.

(cherry picked from commit 3cb49f0, adapted to main's runner anchor)

* test(gateway): probe startup readiness on fresh connections

The deferred-fleet startup test failed twice in 2026.10.5 FRV openclaw#12 with
`fetch failed` / `read ECONNRESET`. Its Gateway shares the test process's
event loop. A /healthz or /readyz probe could reuse a keep-alive socket
that Undici still treated as live; when the request was written and a
synchronous main-thread startup stall followed, the server's idle-timer
callback ran before the poll phase read the request and destroyed the
socket with the request unread, so the kernel reset the connection.

main still probes with default keep-alive fetches. Probe with
`Connection: close`, matching existing Gateway test probes. Assertions are
unchanged.

(cherry picked from commit e3c63f2, adapted to main's probe sites)

* test(live): expect review effort for Skill Workshop background reviews in the Ultra lane

Since openclaw#161057 the Skill Workshop counts iterations per session, so Ultra probe
sessions trigger a background review after idling. The review runs under its
own skill-workshop-review: run and does not inherit the session's thinking
level, so the lane's every-request-is-max assertion failed on 2026.10.5
whenever a review reached the provider.

On main, openclaw#173889 pins review runs to thinkLevel "low" (review-run.ts), which
the OpenAI stream wrapper sends as effort "low". Expect that effort for review
runs; Ultra runs and their sessions must still be max, and independent
heartbeats stay medium.

The live file is over the line cap, so the Ultra wire effort policy moves to
a sibling helper with its observation type, and the deterministic review
cases run in the normal helper suite.

(cherry picked from commit ca15213, adapted to main's review thinking level)

* test(release): forward-port 2026.10.4-line upgrade-survivor and runtime-smoke harness fixes

Release-line harness fixes that 2026.10.1-2026.10.5 carried but main never
received:

- cron-scheduled-authority: seed the cron authority specimen through the
  published baseline's own SQLite writer (seedPublishedCronJobs) instead of a
  raw cron/jobs.json that current candidates treat as a retired pre-July
  store; drop owner fields for pre-2026.7.1 baselines
  (usesCronOwnerAtBaseline). The dispatcher passes the package root to
  seedState, and the scenario now requires a published baseline.
- bundled plugin runtime smoke: join deferred read-only update discovery via
  update.status before the package-manager child watchdog. main still defers
  install discovery (`<manager> root -g`) until after ready, so it can race
  the watchdog's no-package-manager-children check.

Skips the codex npm plugin live source-reply grep from the release commit:
main already probes dynamic-tool-source-reply.ts and dynamic-tools.ts.

(cherry picked from commit fcdf0d1, codex grep hunk dropped; cron seed
test adapted to main's executable-mode fixture writes)
RomneyDa added a commit that referenced this pull request Oct 27, 2026
…sters (#175278)

The #169144 backport converts a non-announcing child interrupted by a
Gateway restart into a private parent continuation only when the captured
requester has both a session id and a lifecycle revision. Sessions created
implicitly by the `agent` RPC (and other paths that never patch a new
session) carry no lifecycle revision, so the orphan settled terminal with
no completionTarget or requester settle wake and the parent never received
the "Reconcile every listed unfinished child" turn.

Every downstream requester identity check already compares the captured
revision by equality (absent matches absent, and a reset assigns a new
revision), and private spawn only requires a requester session id. Apply
the same requirement here.

The native live subagent restart proof starts its parents through `agent`,
which is why its parent-handoff assertion timed out; the crash-loop breaker
only delayed settlement. A quiet-child e2e twin started via `agent` failed
with and without the breaker before this change and receives the parent
reconcile turn within a second of settlement after it.

(cherry picked from commit 8d4591a)
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 gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: L 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