Skip to content

fix: finish replies to subagent results after a Gateway restart - #200924

Merged
steipete merged 1 commit into
mainfrom
codex/subagent-committed-restart-continuation
Nov 18, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/subagent-committed-restart-continuation

Conversation

@steipete

@steipete steipete commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A Gateway restart can interrupt a requester after it has read a subagent result but before it answers. Crash recovery could leave that requester parked indefinitely, so the result was present in its conversation but the user never received the final reply.

User Impact

The Gateway resumes that interrupted requester turn from its saved conversation. Completion inputs are delivered once, and intentional Stop and current authority checks still apply. No protocol, schema, or configuration changes are required.

Why This Change Was Made

Startup classified any retained requester-settle cohort as yield-waiting, including an interrupted execution whose exact settle input was already committed (session-restart-resume.ts:511 on base). The registry's consumed-input check ran only after dispatch (subagent-announce.requester-settle-wake.ts:648 on base), allowing an unnecessary resubmission to conflict with the committed input.

Gateway restart-resume now recognizes the committed input for the interrupted settle run and uses the existing restart admission and continuation path. The registry settles consumed receipts before dispatch. This preserves delivered-on-commit semantics: the registry owns unconsumed results, while the Gateway owns completing a requester turn that already consumed its input. No new state, continuation owner, replay path, or authority fallback is added; queued-input ordering and store/cancellation guards remain intact.

The existing graceful-shutdown checkpoint now permits delivered, as required by #200249. The final assertions still require HUB_RECEIVED_RESTART_COMPLETION, exactly one completion input, exactly one final reply, and no duplicate after a second restart. Self-simplification retained the existing owners and receipts. The test budget is raised from zero to exactly +15 net lines to extend an existing parked-requester case with a real committed settle input; no additional Gateway boot or test case is added. An ended execution without a terminal status remains deliberately yielded, preserving registry ownership of its wait.

Evidence

On base 8f16d1323f8fac4dec49d97267f5c11edf30ef8c, after correcting that checkpoint, the focused command reports 1 failed, 1 passed, 8 skipped: (announcing-crash) misses HUB_RECEIVED_RESTART_COMPLETION; graceful (announcing) passes. The earlier uncorrected cases both failed on the base and head of #200873, as recorded there.

pnpm test test/gateway-subagent-completion-restart.e2e.test.ts --maxWorkers=1 -t 'restart \(announcing(-crash)?\)'
# Base: Tests 1 failed | 1 passed | 8 skipped (10)

pnpm test test/gateway-subagent-completion-restart.e2e.test.ts --maxWorkers=1
# Fix: Tests 10 passed (10), 335.63s Vitest

This proof runs isolated real Gateway processes, a synthetic local model endpoint, and native SQLite custody across graceful shutdown, process crashes, and subsequent restarts. It includes public/private announcing, nested, captured, busy, retrying, unmarked, and stale-settle cases.

All 89 focused tests pass across restart, requester dispatch, and custody suites, including real Stop, authority refusal, queued inputs, and deliberate yield. The extended committed-input yield case first failed against the initial candidate (1 failed, 9 skipped) and then passed with the lifecycle distinction. Core and affected Gateway/root-test typechecks, touched-file lint/format, line-cap and identity ratchets, and the final pnpm build pass. Fresh independent Codex autoreview is scoped-clean through P2.

The local broad sibling command completed four shards with 842 passed before its remaining agents-support shard was stopped under shared-host contention; that incomplete shard is not claimed as passing. Exact-head PR CI supplies the remaining broad proof.

Related: #200873, #200823, #200249.

Inherited CI failures

CI run 44221908417 fails only checks-node-changed-3 and its aggregate gate. Its two Workshop learning cases reproduce on both this PR and the exact CI main baseline e93a426be3297ed947f54b4e15c87827225b6c90 (2 failed on each): the review request exceeds the old 64 KiB expectation, and the learned-skill notice is absent. The first expectation predates #200545, which intentionally removed that clamp; the notice failure is also inherited. The failing tests and inspected Workshop/fork source inputs are unchanged in the tested merge. Security and all other jobs pass. These failures remain recorded as failures and use the native inherited-failure landing exception.

pnpm test src/gateway/gateway-workshop-learning.e2e.test.ts --maxWorkers=1 -t 'patches a learned skill|sends one bounded review request'
# PR: Tests 2 failed (2); baseline: Tests 2 failed (2)

@clawsweeper

clawsweeper Bot commented Nov 18, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T02:18:39.852721Z 9584f5d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: S labels Nov 18, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 18, 2026
@clawsweeper

clawsweeper Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Resume interrupted requester turns whose subagent results are already committed, while settling those results without replay.

Example: The Gateway crashes after CAPTURED_CUSTODY_RESULT reaches the requester transcript but before the requester answers.

  • Before: The requester can remain parked and never produce HUB_RECEIVED_RESTART_COMPLETION.
  • After: Normal restart recovery continues the requester, while the completion input remains recorded exactly once.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused implementation and regression coverage are convincing, but the supplied evidence remains test-only under the required real-behavior proof standard.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A requester can read a completed subagent result, be interrupted by a Gateway crash, and never answer the user.
Reason: The maintainer-authored direction restores an existing completion contract with a focused change to its current owners.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR addresses a current restart-recovery defect through the existing owners, with no concrete correctness or security finding.

Priority: P1
Reviewed head: 9584f5def748e160df7c92c21e89b14907d7ed42

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supply redacted Gateway runtime output showing a crash after committed completion input, one recovered final reply, and no replay after another restart; redact credentials and non-public endpoints.
Agent review details

How this fits together

The subagent registry delivers child results into requester conversations; Gateway startup recovers interrupted turns using persisted lifecycle and transcript facts.

flowchart TD
A[Child result] --> B[Registry completion owner]
B --> C[Requester transcript]
C --> D[Gateway restart classification]
D --> E[Fresh turn admission]
E --> F[Requester reply]
C --> B
Loading

Technical review

Best possible solution:

Keep registry ownership for unconsumed results and use ordinary Gateway recovery to finish interrupted turns with committed input.

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

The current-main classification and post-dispatch consumed check expose the reported path, corroborated by the base failure recorded in this PR and the preceding merged repair; no target code was executed during this review.

Is this the best way to solve the issue?

The patch repairs the ownership boundary using existing transcript receipts and restart admission, and preserves deliberate yield rather than introducing another replay mechanism.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 3460f6178601.

Provenance checked

  • Restart classification and custody keeps the original intent (ad6738d: Recover retained child obligations under fresh requester authority before classifying startup waits.)
  • Registry-owned requester-settle recovery changes intended behavior with a stated reason (66273da: Avoid competing Gateway turns for registry-owned results; this PR explains why a committed input transfers interrupted-turn continuation to the Gateway.)
  • Consumed-result settlement keeps the original intent (b601a4b: A result already committed to the requester transcript must never be replayed.)
  • Graceful-shutdown delivery checkpoint changes intended behavior with a stated reason (6d7a56d: Persist requester consumption separately from the final reply; allowing delivered at shutdown follows the later delivered-on-commit contract while preserving final outcome assertions.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit ad6738d adds src/gateway/session-restart-resume-custody.ts:34 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ad6738d48408; files: src/gateway/session-restart-resume-custody.ts)
  • Ayaan Zaidi: Raw commit b601a4b adds src/agents/subagents/announce/subagent-announce.requester-settle-wake.ts:643 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b601a4b206c2; files: src/agents/subagents/announce/subagent-announce.requester-settle-wake.ts)

PR surface

Source +35, Tests +15, Docs +6. Total +56 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 38 3 +35
Tests 2 18 3 +15
Docs 2 13 7 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 69 13 +56

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P1: A Gateway crash can leave an active delegated workflow indefinitely without its final requester reply.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: A Gateway crash can leave an active delegated workflow indefinitely without its final requester reply.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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.

Reviewed November 17, 2026, 9:30 PM ET / November 18, 2026, 02:30 UTC.

@steipete
steipete merged commit 61daf4c into main Nov 18, 2026
140 of 146 checks passed
@steipete
steipete deleted the codex/subagent-committed-restart-continuation branch November 18, 2026 03:00
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 23, 2026
…200924)

Release adaptation: Reviewed committed-input restart classification and consumed-cohort dedup; preserve partition cancellation and ambiguity/refusal guards. Move reviewed Gateway-closure extraction to its introducing row15 so each source pick remains below line cap. Policy combination exposed stage20 700->702 line-cap growth. Pure relocation of captured generation and unchanged predicate together into existing requester-settle-state owner (capture retains value snapshot/type guard and undefined-generation comparison); no assertions/coverage removed. Predicate-only intermediate still measured701; complete capture reduces wake to700.

(cherry picked from commit 61daf4c)

Co-authored-by: RomneyDa <[email protected]>
@conrathchad3-netizen

Copy link
Copy Markdown

It's happening and I'm not happy. Are we good? He is mirroring GitHub through chrome and saying the entire thing was fake?

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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S 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.

2 participants