Skip to content

fix: resumed main-session turn after a gateway restart is delivered to the session's last route instead of silently completing - #127342

Merged
steipete merged 2 commits into
openclaw:mainfrom
ernestrolfson-design:fix/restart-recovery-resume-session-route
Aug 25, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
ernestrolfson-design:fix/restart-recovery-resume-session-route

Conversation

@ernestrolfson-design

@ernestrolfson-design ernestrolfson-design commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #127339.

What Problem This Solves

When the Gateway restarts during a main-session turn, startup recovery can resume an unclaimed interrupted session and write its completed answer to the transcript without delivering that answer to the channel where the conversation happened. The user experiences a silent dropped response even though the model believes it replied.

Why This Change Was Made

The successful resume owner called the existing restart-recovery delivery-context resolver without opting into the authoritative delivery route already persisted on the session. Its sibling failure-notice owner already enables that same route. This change enables the existing owner-controlled route for successful recovery as well; it adds one production line and introduces no new configuration, persistence shape, protocol, transport fallback, or authority.

The shared resolver still rejects claimed transcript-only recovery, non-deliverable or incomplete destinations, and denied send policies. Explicit run-owned delivery context retains precedence, and message-tool-only recovery continues to require its existing trusted channel authority.

The original exact-head CI also exposed an obsolete QA catalog assertion that enumerated exactly 15 restart scenarios. The new scenario already correctly declared isolated execution and a meaningful isolation reason; the test failed solely because it became the 16th valid scenario. The catalog now requires nonempty discovery and checks isolation across every discovered restart scenario, while specifically verifying this new scenario declares its reason. Existing scenarios whose optional reason is absent remain compatible.

User Impact

After an interrupted Gateway restart, users receive the recovered answer in the original conversation instead of silently losing it. Existing transcript-only recovery, denied send policies, and trusted tool-authority restrictions remain unchanged. Future correctly isolated restart scenarios no longer break QA because of a stale scenario inventory.

Evidence

Before the production fix, the expanded owner-boundary regression passed for the existing claimed delivery route but failed for the unclaimed persisted route: recovery requested deliver: false and emitted no channel delivery. After the fix, both routes call the real outbound adapter and reply-payload hook exactly once with the expected channel, destination, account, and thread. Send-policy denial is covered for both route sources.

The catalog regression was separately reproduced before its repair: requires explicit suite isolation for gateway state restart scenarios failed with 16 actual scenarios versus the obsolete 15-item snapshot, specifically because gateway-restart-unclaimed-delivery was present.

OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs extensions/qa-lab/src/scenario-catalog.test.ts src/agents/main-session-recovery/main-session-restart-recovery.test.ts

171 recovery tests passed
58 QA catalog tests passed
229 tests passed total

The isolated QA scenario crosses the real changed boundary: a genuine qa-channel inbound turn records the canonical session route; its ephemeral Gateway is stopped; an interrupted user turn is persisted with no recovery delivery claim or run-specific context; the replacement Gateway automatically recovers that session using the mock provider; and the original qa-channel receives exactly one completed response, followed by a 1.5-second no-duplicate quiet window.

OPENCLAW_VITEST_MAX_WORKERS=1 pnpm openclaw qa suite --provider-mode mock-openai --scenario gateway-restart-unclaimed-delivery --concurrency 1 --output-dir .artifacts/qa-e2e/issue-127339-restored-pass

Passed: 1
Failed: 0
{
  "channel": "qa-channel",
  "recoveredMarker": "UNCLAIMED-RECOVERY-DELIVERED-OK",
  "delivered": "UNCLAIMED-RECOVERY-DELIVERED-OK",
  "outboundCount": 1,
  "deliveryClaimBeforeRestart": false
}

Exact reviewed head: 4a48fdb46b1157e0e4ae7ab6e5ef04ada1ebd96e. Structured full-branch review and independent source-only review found no actionable defects. The existing claimed-route, transcript-only, deny-policy, reply-hook, and trusted message-tool authority sibling coverage remains green. Production delta: +1 line; owner regression tests +153/-131 (net +22), catalog isolation regression +7/-17 (net -10), and real-Gateway QA scenario +181 lines. Original fix and primary contribution: Ernest Rolfson (@ernestrolfson-design).

@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

You have reached your Codex usage limits for security reviews. Please try again later.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Aug 21, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. 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 Aug 21, 2026
@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 6:39 PM ET / 22:39 UTC.

ClawSweeper review

What this changes

The PR makes an unclaimed interrupted main-session turn deliver its recovered reply through the session’s persisted route after a Gateway restart, with regression and QA coverage.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open. Current main still omits the persisted-route opt-in for resumed turns; this PR adds the constrained existing fallback with no blocking defect found. Its mock-Gateway QA proof is sufficient; wait for queued exact-head checks before merge.

Priority: P1
Reviewed head: 4a48fdb46b1157e0e4ae7ab6e5ef04ada1ebd96e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary fix with strong harness evidence and no actionable patch defect found.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body provides after-fix isolated Gateway-and-qa-channel output showing exactly one recovered outbound reply; this satisfies the repository’s mock-gateway harness proof rule.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body provides after-fix isolated Gateway-and-qa-channel output showing exactly one recovered outbound reply; this satisfies the repository’s mock-gateway harness proof rule.
Evidence reviewed 9 items Current-main behavior: Current main calls the resolver without enabling its persisted-session fallback, leaving an unclaimed row without a run-specific context non-deliverable.
Resolver invariant: The shared resolver only takes the session route when enabled and no active delivery claim exists, then rejects incomplete, undeliverable, and send-policy-denied routes.
Patch ownership boundary: The PR enables that existing fallback solely in resumed-turn dispatch, where the resolved context is converted to automatic delivery.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw qa suite --provider-mode mock-openai --scenario gateway-restart-unclaimed-delivery --concurrency 1

Result: FAIL (failed) — step 1 run pnpm openclaw qa suite --provider-mode mock-openai --scenario gateway-restart-unclaimed-delivery --concurrency 1: previous terminal command was still running after 30 seconds: "pnpm openclaw qa suite --provider-mode mock-openai --scenario gateway-restart-unclaimed-delivery --concurrency 1"

$ node scripts/run-node.mjs qa suite --provider-mode mock-openai --scenario gateway-restart-unclaimed-delivery --concurrency 1
[openclaw] Building TypeScript (dist is stale: missing_private_qa_dist - private QA dist entry missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 85.51 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.6s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 12.5s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 3634ms (slowest: built plugin control-plane loads 2825ms)
│
◇

OpenClaw 2026.8.1 (4a48fdb) — I schedule my existential crises with cron so they never block your messages.

[qa-suite] run start: scenarios=1 concurrency=1 transport=qa-channel
[qa-suite] lab start
[qa-suite] lab ready: http://127.0.0.1:40785
[qa-suite] provider start: mock-openai
[qa-suite] provider ready: http://127.0.0.1:43223
[qa-suite] gateway start

Assertions:

  • FAIL expect_output: UNCLAIMED-RECOVERY-DELIVERED-OK
  • FAIL expect_output: Passed: 1

How this fits together

Gateway restart recovery resumes interrupted main-session turns after startup. It resolves an allowed delivery route, checks policy, and hands the completed reply to the channel adapter.

flowchart LR
  A[Interrupted main-session turn] --> B[Gateway restart]
  B --> C[Restart recovery]
  C --> D[Delivery route resolution]
  D --> E[Send policy check]
  E --> F[Outbound channel reply]
Loading

Before merge

  • Resolve merge risk (P1) - Automatic recovery will now send an answer to an unclaimed session’s persisted route; exact-head coverage must retain claim precedence, policy denial, and no-duplicate delivery.
  • Resolve merge risk (P1) - Production growth is one owner-boundary opt-in to an existing resolver; making the resolver default-on would broaden behavior for its other caller, so there is no clearer net-neutral refactor.
  • Resolve merge risk (P1) - The reviewer could not rerun the harness in this read-only environment; the contributor’s recorded QA result is the available runtime proof.
  • Complete next step (P2) - This PR already contains the focused repair; it needs normal exact-head validation rather than a ClawSweeper repair job.
Agent review details

Security

None.

PR surface

Source +1, Tests +12, Other +181. Total +194 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 0 +1
Tests 2 160 148 +12
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 181 0 +181
Total 4 342 148 +194

Review metrics

Metric Value Why it matters
Production versus test delta production +1; tests and QA test-support +193 net The single production opt-in changes automatic delivery after restart, while the added coverage exercises route precedence, policy denial, and a Gateway boundary.

Stored data model

Persistent data-model change detected: serialized state: qa/scenarios/runtime/gateway-restart-unclaimed-delivery.yaml, vector/embedding metadata: src/agents/main-session-recovery/main-session-restart-recovery.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #127339
Summary: This PR is the candidate fix for the linked unclaimed restart-recovery delivery gap.

Members:

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

Merge-risk options

Maintainer options:

  1. Gate on exact-head delivery coverage (recommended)
    Merge after the queued checks confirm one delivery for the unclaimed persisted route while claimed and denied-policy paths remain suppressed.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Require exact-head coverage for unclaimed persisted-route delivery, claim precedence, send-policy denial, and no duplicate outbound reply.

Technical review

Best possible solution:

Merge the existing-resolver opt-in once exact-head checks confirm its claimed-route, send-policy, and no-duplicate safeguards.

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

Yes, at source level: current main leaves the resolver fallback disabled at the resumed-turn call site, while the resolver admits the persisted route only when that flag is enabled and no active claim exists.

Is this the best way to solve the issue?

Yes: this is the narrowest owner-boundary repair because it reuses the existing normalized, policy-checked resolver rather than introducing a parallel delivery path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3f6f6799e95c.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • remove rating: 🦞 diamond lobster: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P1: This fixes a silent lost channel reply after restart recovery, a broken agent/channel workflow.
  • merge-risk: 🚨 message-delivery: The PR changes the automatic destination used for a recovered reply after Gateway restart.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster 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 PR body provides after-fix isolated Gateway-and-qa-channel output showing exactly one recovered outbound reply; this satisfies the repository’s mock-gateway harness proof rule.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix isolated Gateway-and-qa-channel output showing exactly one recovered outbound reply; this satisfies the repository’s mock-gateway harness proof rule.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame attributes the missing resumed-turn call and related restart-recovery authority code to Peter Steinberger. (role: recent area contributor; confidence: high; commits: a6ebad9964c4, 4a48fdb46b11; files: src/agents/main-session-recovery/main-session-restart-dispatch.ts, src/config/sessions/restart-recovery-state.ts)

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 (6 earlier review cycles)
  • reviewed 2026-08-21T18:10:25.043Z sha 1918e2c7eed09b60bc7ae5e653fd6434382835a4 :: needs real behavior proof before merge. :: none
  • reviewed August 22, 2026, 10:49 PM ET / August 23, 2026, 02:49 UTC sha unknown :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-24T02:10:12.756Z sha 1918e2c7eed09b60bc7ae5e653fd6434382835a4 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-24T02:33:08.487Z sha 1918e2c7eed09b60bc7ae5e653fd6434382835a4 :: needs real behavior proof before merge. :: none
  • reviewed August 25, 2026, 3:40 AM ET / 07:40 UTC sha unknown :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-25T16:41:17.684Z sha cc60ecb :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the fix/restart-recovery-resume-session-route branch from 1918e2c to cc60ecb Compare August 25, 2026 16:29
@openclaw-barnacle openclaw-barnacle Bot added extensions: qa-lab size: M triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 25, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 25, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Aug 25, 2026
@steipete
steipete merged commit dfe29ed into openclaw:main Aug 25, 2026
670 of 676 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 26, 2026
…o the session's last route instead of silently completing (openclaw#127342)

* fix(agents): deliver unclaimed restart recoveries to session route (openclaw#127339)

Co-authored-by: Peter Steinberger <[email protected]>

* test(qa): validate restart isolation without stale inventory

---------

Co-authored-by: Peter Steinberger <[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 extensions: qa-lab merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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

2 participants