Skip to content

fix: resume main sessions after gateway restarts - #121969

Merged
steipete merged 13 commits into
mainfrom
steipete/gateway-restart-recovery-2628de
Aug 11, 2026
Merged

steipete merged 13 commits into
mainfrom
steipete/gateway-restart-recovery-2628de

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users with an in-flight main-session turn could lose automatic continuity after a Gateway restart when the transcript, delivery receipt, approval, Code Mode checkpoint, or reply-hook checkpoint was ambiguous. OpenClaw marked the session failed and asked the user to resend the request even though the model still had the transcript and could safely reconcile what remained.

It also fixes the Control UI attributing the internal restart continuation to the signed-in human, including their avatar and name, because the persisted continuation is a user-role transcript row with internal-system provenance.

Why This Change Was Made

The recovery policy now has only complete and resume outcomes. Delivered terminal replies and handled-silent hooks still complete without dispatch. Every former ordinary fail shape resumes; ambiguous side-effect states use forceRestartSafeTools, while Code Mode controls are enabled only for an exact replay-safe checkpoint. The continuation prompt and pending-text note remain byte-identical.

The normal reply-hook pre-resume gate was removed. Restart recovery dispatches an ordinary Gateway agent turn: embedded and CLI runtimes classify it as a user trigger, so currently loaded before_agent_reply hooks run, along with normal agent-run, transcript-write, and outbound-delivery hooks. Ingress-only before_dispatch and reply_dispatch hooks are not re-run on the internal continuation. The deleted direct resend notice bypassed the agent pipeline entirely, so it was a worse hook boundary.

The one hard security boundary remains: a message_tool_only recovery without a durable channel-ingress authority claim is tombstoned through the existing terminal flow. Exact pending delivery-queue owners also remain authoritative and defer a second dispatch. The terminal notice accurately directs the user to /new or /reset, which is required for tombstoned sessions.

Removed paths and state-machine surface:

  • action: "fail" from MainSessionResumePolicy
  • fail_recovery, failUnresumableMainSession, and UNRESUMABLE_SESSION_NOTICE
  • the recovery-only reply-hook block helper and tests
  • main-session-restart-recovery-notice.ts
  • the small standalone recovery-claim module, consolidated into its owner
  • current writers for admitted, continue, and handled-unrecoverable hook phases; their published type literals remain read-compatible because they are transitively exposed by the Plugin SDK Agent Harness contract

The bounded legacy abort-text window remains because v2026.7.2-beta.5 shipped restart recovery before coded abort tails; a direct upgrade can still surface that transcript.

Accepted tradeoffs:

  • Possible duplicate reply on ambiguous delivery: preferred over a dead session. The model sees the transcript, while restart-safe tool filtering prevents silent re-execution of ambiguous side effects.
  • Hook-gate removal: preferred because the recovery turn runs through the normal agent pipeline and active user-trigger hooks apply; the old direct notice bypassed those hooks.

Production LOC: +200/-436 (net -236). Tests: +462/-961 (net -499). Docs: +36/-41 (net -5).

AI-assisted implementation; all changes were reviewed with the repository autoreview workflow.

User Impact

Main sessions now continue automatically after a Gateway restart instead of demanding a manual resend for transcript ambiguity. If previous delivery or tool side effects are uncertain, the agent can inspect the transcript and explain where things stand without receiving unsafe mutation tools.

In the Control UI, visible provenance.kind === "internal_system" user-role rows render as subdued System notices with no operator avatar or name. Existing message visibility, ordering, timestamps, search filtering, and user-turn grouping remain intact. Other hidden internal-system sources remain hidden.

Control UI before and after

Before: attributed to the operator After: system row
Before: restart recovery text rendered as a Riley user bubble After: restart recovery text rendered as a centered System row

Evidence

Pre-fix regressions failed for 14 former terminal policy shapes and for the Control UI internal-system projection. They pass after the owner-boundary repair.

Focused and full proof:

  • node scripts/run-vitest.mjs src/agents/main-session-recovery/ — 12 files, 619 tests passed
  • node scripts/run-vitest.mjs ui/src/pages/chat/chat-thread.test.ts ui/src/pages/chat/components/chat-message.test.ts — 2 files, 353 tests passed
  • node scripts/run-vitest.mjs src/auto-reply/reply/agent-runner.runreplyagent.e2e.test.ts — 1 file, 141 tests passed
  • focused pending-final and delivery-completion tests — 8 tests passed
  • focused Control UI SQLite admission test — 2 tests passed
  • node scripts/check-changed.mjs — passed all selected core, core-test, UI, and docs lanes after remote routing was unavailable and the wrapper fell back to local execution
  • final autoreview: clean, no accepted/actionable findings

Mock-Gateway QA Lab verdict from the exact PR head:

{
  "scenario": "gateway-restart-inflight-run",
  "status": "pass",
  "step": {
    "name": "completes one in-flight run across restart",
    "status": "pass",
    "details": "session=agent:qa:main plannedTool=wait persistedTail=assistant/toolUse/wait recoveredTail=assistant/stop/text recoveredMarkers=1 resendNotices=0 restartSafePolicy=true recoveryPromptHeartbeat=false\nRESTART-CODE-MODE-WAIT-OK"
  },
  "counts": {
    "total": 1,
    "passed": 1,
    "failed": 0,
    "skipped": 0
  },
  "providerMode": "mock-openai",
  "model": "mock-openai/gpt-5.6-luna"
}

Command:

pnpm openclaw qa suite --provider-mode mock-openai --concurrency 1 --scenario gateway-restart-inflight-run --output-dir .artifacts/qa-e2e/gateway-restart-inflight-run-pr-head

@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Aug 11, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 11, 2026
@clawsweeper

clawsweeper Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 11, 2026, 5:53 AM ET / 09:53 UTC.

ClawSweeper review

What this changes

This PR resumes interrupted main sessions through the normal agent pipeline after Gateway restart and renders internal continuation prompts as System notices in Control UI.

Regression provenance

Possible regression — probable (reviewed change; reproduction). No predecessor PR is attributed.

Merge readiness

⛔ Blocked by patch quality or review findings - 7 items remain

Keep open. The prior P1 remains: an interrupted reply hook can be invoked again after restart before restart-safe tool filtering applies. The Control UI update also leaves live recovery stream/tool placement attached to the prior turn under clock skew.

Priority: P1
Reviewed head: a2750f64ce9c5bf25a7f09121b344bbafe1cafdc

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The branch has useful recovery and UI evidence, but two concrete boundary regressions block merge.
Proof confidence 🌊 off-meta tidepool Not applicable: Not applicable to this maintainer-authored PR; its body nonetheless includes exact-head mock-Gateway and UI screenshot evidence.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable to this maintainer-authored PR; its body nonetheless includes exact-head mock-Gateway and UI screenshot evidence.
Evidence reviewed 6 items Pending hook replay: The PR maps a durable before_agent_reply state of pending to a new resumed turn, although pending means the prior hook began and its side effects are unknown.
Hook precedes model-tool filtering: The hook observer invokes its handler after durable admission; restart-safe filtering is applied later while assembling model tools, so it cannot prevent a duplicate plugin callback.
Existing restart contract: Current main documents that recovery never replays an interrupted hook and fails closed while an active hook cannot be proven safe across restart; the PR reverses that behavior.
Findings 2 actionable findings [P1] Do not replay an ambiguous before-agent-reply hook
[P2] Keep recovery notices as live projection boundaries
Security None None.

How this fits together

Gateway restart recovery reads persisted session state, decides whether to resume or tombstone a turn, then dispatches an internal continuation through the agent pipeline. Control UI projects that persisted continuation and its live output into chat rows.

flowchart LR
  A[Gateway restart] --> B[Persisted main session]
  B --> C[Recovery policy]
  C -->|resume| D[Agent pipeline]
  C -->|tombstone| E[Terminal notice]
  D --> F[Transcript and live output]
  F --> G[Control UI chat rows]
Loading

Before merge

  • Do not replay an ambiguous before-agent-reply hook (P1) - pending is recorded immediately before the hook runs. Returning resume starts a new user-triggered agent run, so the hook can execute again before forceRestartSafeTools filters model tools. A hook that completed an external side effect before restart can therefore duplicate it; preserve terminal settlement here or establish durable per-hook idempotency.
  • Keep recovery notices as live projection boundaries (P2) - The System notice replaces the persisted recovery user row, but live run insertion still recognizes only message user rows. A recovery stream or tool with an earlier clock timestamp can be inserted before this notice and appear under the interrupted turn. Preserve its run identity and use startsTurn when calculating live insertion bounds.
  • Resolve merge risk (P1) - A restart after an external before_agent_reply side effect can run that callback twice, despite the restart-safe model-tool restriction.
  • Resolve merge risk (P1) - A skewed live recovery stream or tool can render beneath the interrupted user turn rather than the System recovery boundary.
  • Complete next step (P2) - This maintainer-authored, maintainer-labeled PR needs the two author-owned boundary repairs before normal merge review can continue.
  • Improve patch quality - Preserve no-replay behavior for an ambiguous pending reply hook or add durable hook idempotency with a restart regression.
  • Improve patch quality - Add a clock-skewed live recovery stream/tool test that proves the System notice is the insertion floor.

Findings

  • [P1] Do not replay an ambiguous before-agent-reply hook — src/agents/main-session-recovery/main-session-restart-recovery-resume-policy.ts:395-397
  • [P2] Keep recovery notices as live projection boundaries — ui/src/pages/chat/chat-thread-build.ts:271-282
Agent review details

Security

None.

PR surface

Source -236, Tests -442, Docs -5. Total -683 across 35 files.

View PR surface stats
Area Files Added Removed Net
Source 22 270 506 -236
Tests 11 520 962 -442
Docs 2 36 41 -5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 35 826 1509 -683

Review metrics

Metric Value Why it matters
Production versus test delta production +200/-436 (net -236); tests +462/-961 (net -499) The branch is net-negative, but its broad recovery-state rewrite still needs the two boundary regressions resolved before merge.

Stored data model

Persistent data-model change detected: serialized state: src/agents/main-session-recovery/main-session-restart-recovery-resume-policy.test.ts. Confirm migration or upgrade compatibility proof before merge.

Mantis proof suggestion

A redacted web chat proof would directly show that restart recovery is displayed as a System row and that subsequent continuation output is associated with it. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis web UI chat proof: verify that a Gateway restart renders the recovery input as a System row and keeps its live continuation output below that row.

Merge-risk options

Maintainer options:

  1. Repair both recovery boundaries (recommended)
    Keep pending hook recovery out of replay unless durable hook idempotency is available, and make live run-bound insertion recognize the System recovery notice.
  2. Pause the always-resume policy
    Do not merge the policy reversal unless maintainers intentionally accept duplicate plugin side effects and define the corresponding plugin contract.

Technical review

Best possible solution:

Retain terminal settlement for ambiguous pending hooks until durable per-hook idempotency exists, and preserve recovery-run identity when using System notices as live insertion boundaries.

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

Yes. A persisted pending reply-hook state plus a side-effecting hook reproduces the duplicate-callback path from source; a recovery notice with a skewed live segment reproduces the UI association path.

Is this the best way to solve the issue?

No. Restart-safe model tools do not make a previously started plugin callback idempotent, and the UI boundary must also participate in live insertion bounds.

Full review comments:

  • [P1] Do not replay an ambiguous before-agent-reply hook — src/agents/main-session-recovery/main-session-restart-recovery-resume-policy.ts:395-397
    pending is recorded immediately before the hook runs. Returning resume starts a new user-triggered agent run, so the hook can execute again before forceRestartSafeTools filters model tools. A hook that completed an external side effect before restart can therefore duplicate it; preserve terminal settlement here or establish durable per-hook idempotency.
    Confidence: 0.99
  • [P2] Keep recovery notices as live projection boundaries — ui/src/pages/chat/chat-thread-build.ts:271-282
    The System notice replaces the persisted recovery user row, but live run insertion still recognizes only message user rows. A recovery stream or tool with an earlier clock timestamp can be inserted before this notice and appear under the interrupted turn. Preserve its run identity and use startsTurn when calculating live insertion bounds.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4b08d9aa75c1.

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: Existing plugins can observe a changed restart contract: an interrupted before_agent_reply callback may now be invoked again.
  • add merge-risk: 🚨 session-state: Recovery output can be visually associated with the preceding interrupted turn when timestamps are skewed.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • remove proof: sufficient: Current real behavior proof status is not_applicable, not sufficient.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.
  • remove merge-risk: 🚨 other: Current PR review merge-risk labels are merge-risk: 🚨 compatibility, merge-risk: 🚨 session-state.

Label justifications:

  • P1: The branch can duplicate external plugin side effects during a user-visible main-session recovery.
  • merge-risk: 🚨 compatibility: Existing plugins can observe a changed restart contract: an interrupted before_agent_reply callback may now be invoked again.
  • merge-risk: 🚨 session-state: Recovery output can be visually associated with the preceding interrupted turn when timestamps are skewed.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: Not applicable to this maintainer-authored PR; its body nonetheless includes exact-head mock-Gateway and UI screenshot evidence.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Authored the current-main repair that prevents replay after final delivery, touching the recovery decision surface. (role: recent restart-recovery contributor; confidence: high; commits: 210aca6de387; files: src/agents/main-session-recovery/main-session-restart-recovery-resume-policy.ts, src/agents/main-session-recovery/main-session-restart-dispatch.ts)
  • steipete: Has carried substantial session/reply lifecycle refactors and authored this recovery redesign. (role: recent session and reply-lifecycle contributor; confidence: high; commits: ce53f7e82e25, 408abcd46f9e, a2750f64ce9c; files: src/auto-reply/reply/restart-recovery-claim.ts, src/agents/main-session-recovery/main-session-restart-recovery-store.ts)
  • Hannes Rudolph: Recent history includes the scoped reply-hook recovery work that defines the affected plugin behavior. (role: plugin-hook recovery contributor; confidence: medium; commits: 6dc55fa65e21; files: src/plugins/before-agent-reply.ts, src/auto-reply/reply/restart-recovery-claim.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 (1 earlier review cycle)
  • reviewed 2026-08-11T09:04:17.209Z sha 1100198c7cdf29bffe3b088434fb5b0ab193e4d6 :: found issues before merge. :: [P1] Do not replay an ambiguous before-agent-reply hook | [P2] Preserve recovery notices as boundaries in every chat projection

@steipete
steipete marked this pull request as ready for review August 11, 2026 09:12
@steipete
steipete force-pushed the steipete/gateway-restart-recovery-2628de branch from 6d87ab8 to c79cb97 Compare August 11, 2026 09:34
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Aug 11, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Aug 11, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Response to the ClawSweeper review (findings addressed at head a2750f64ce9c5bf25a7f09121b344bbafe1cafdc):

P2 — turn boundaries in every chat projection: fixed. One canonical predicate (chatItemStartsUserTurn in ui/src/pages/chat/chat-turn-boundary.ts) now owns user-turn boundary detection for live insertion windows, tool-turn outcome annotation, and completed-turn work collapse. The inline notice special-case is gone, and regression tests cover collapse and insertion across a recovery notice (ui/src/pages/chat/chat-thread.test.ts).

P1 — ambiguous before_agent_reply replay: skipped, owner decision. The repository owner explicitly chose resume-first recovery. Two facts drive the decision:

  1. The previous fail-closed path did not prevent duplicate hook side effects. It asked the user to resend the request, and that resent message invoked the same before_agent_reply hooks again. The only difference was a human pressing the button; the ambiguity was identical.
  2. The deleted resend notice was delivered through a direct channel send that bypassed the hook pipeline entirely, which is a worse hook boundary than dispatching a normal turn.

Recovery turns now run currently loaded hooks under normal trigger rules. eligibleTriggers scoping remains the plugin-side seam for hooks that must not run on recovered user turns; a durable hook idempotency contract is a reasonable future follow-up but is not a precondition for this repair.

Stored data model: no persisted-shape change. The flagged serialized state is test fixtures; retired hook-state literals (admitted, continue, handled-unrecoverable) are no longer written but remain read-compatible through the Plugin SDK contract type.

Rebase note: the branch was rebased over #121833 preserving its complete-with-durable-debt behavior for ambiguous claimed final sends; resume-first applies only to the remaining genuinely-unfinished states.

@steipete steipete closed this Aug 11, 2026
@steipete steipete reopened this Aug 11, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

CI note for the ui-e2e lane failures on this PR (evidence that they are unrelated to this change):

  • Two runs on head a2750f64ce9 failed on two different tests in checks-ui-e2e (1/4): the claude-sessions virtual-row prepend viewport probe (±1px scroll-anchoring assertion), then session-management.archive.e2e.test.ts > keeps the selected session through archive refreshes (30s timeout waiting for the archived-session Unarchive banner).
  • This branch touches no file under ui/src/e2e/ and no session-management, archive, or virtual-scroll code.
  • On a clean detached origin/main checkout (79016b4), node scripts/run-vitest.mjs ui/src/e2e/session-management.archive.e2e.test.ts fails 3/3 locally with a strict-mode violation (two .agent-chat__input textarea elements mounted — two chat panes at once), the same failure profile as on this branch. The instability ships with current main (recent warm-session-switching / archive-transition churn), independent of this PR.
  • The claude-sessions e2e file passes 4/4 consecutive local runs on this branch.

A follow-up task to stabilize the lane has been filed with the same evidence. Re-firing CI for a green exact-head run.

@steipete steipete closed this Aug 11, 2026
@steipete steipete reopened this Aug 11, 2026
@steipete
steipete merged commit bcaec0c into main Aug 11, 2026
434 of 440 checks passed
@steipete
steipete deleted the steipete/gateway-restart-recovery-2628de branch August 11, 2026 11:01
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 12, 2026
* fix(agents): always resume main sessions after restart

* fix(ui): render internal messages as system rows

* docs: update gateway restart recovery semantics

* refactor(sessions): simplify restart hook checkpoints

* refactor(agents): consolidate restart recovery claims

* test(agents): update delivery recovery revision guard

* fix(plugin-sdk): preserve restart hook state contract

* fix(ui): localize system row label

* test(agents): remove obsolete recovery import

* test(agents): align abort-code propagation with always-resume recovery

* fix(ui): share notice-aware turn boundaries

* test(agents): reconcile restart recovery ownership

* fix(ci): reconcile rebased recovery and UI checks
amittell added a commit to amittell/openclaw that referenced this pull request Aug 21, 2026
…session runs)

Upstream PR openclaw#75662 (head 990fca0)
was amittell-authored, closed unmerged; never in main. Symptom verified live at
branch HEAD: a main session ended via sessions_yield persists status "running"
(no explicit paused projection, no pauseReason), so dashboards, restart
recovery, and follow-up turns cannot distinguish a queued continuation from an
active model turn and race it.

Re-derived for the beta.2 layout (key adaptations vs the old upstream main):
- SessionRunStatus now derives from the gateway-protocol TypeBox
  SessionRowSchema (sessions-row.ts): added Type.Literal("paused") to status
  + optional pauseReason ("sessions_yield"); the derived type cascades to
  SessionEntry.status, sessions-helpers, session-utils.types, and the UI
  re-export — no per-file union edits needed
- protocol artifacts regenerated (pnpm protocol:gen[:swift|:kotlin]):
  GatewayModels.swift gains the pausereason field exactly as upstream
- src/gateway/session-lifecycle-state.ts: yieldedWaiting terminal events now
  project status "paused" + pauseReason "sessions_yield" (error/aborted ends
  still resolve terminally; the marker is gated on the derived status so it
  cannot leak into failed rows); start events clear pauseReason
- broadcast/row plumbing: server-chat.ts snapshotSource.pauseReason,
  session-event-payload.ts pauseReason field, session-utils-row.ts
  buildGatewaySessionRow entry.pauseReason, session-utils.types.ts row type
- src/config/sessions/types.ts: SessionEntry.pauseReason +
  isTerminalSessionStatus now excludes "paused" (nonterminal)
- src/config/sessions/lifecycle.ts:
  resolveTerminalMainSessionTranscriptRegistryCheck skips paused main
  sessions (even with a positive endedAt) so transcript freshness/rotation
  cannot run while the continuation is pending
- src/agents/main-session-recovery/main-session-recovery-state.ts:
  isMainRestartRecoveryCandidate rejects pauseReason "sessions_yield" so
  restart recovery does not force a "[System] previous turn interrupted"
  resume that races the queued continuation
- sessions-list-tool readSessionRunStatus accepts "paused"
- session-entry-slot-keys.ts reserves pauseReason
- UI: isSessionRunActive treats paused as active (nonterminal);
  session-run-state/reconcile status parsing; workboard lifecycle +
  card-actions route through isSessionRunActive; sessions view badge shows
  the explicit Paused label (idle tone, not live); lobster pet outcome skips
  paused rows; en.ts statusPaused + pnpm ui:i18n:sync catalog artifacts
  (statusPaused already in translation memory)
- Superseded upstream pieces NOT re-derived: main-session-restart-recovery.ts
  markRestartAbortedMainSessionsFromLocks second test (function retired by the
  openclaw#121969 re-architecture; isMainRestartRecoveryCandidate now gates the
  marking path), ui i18n meta fallbackKeys/totalKeys edits (beta.2 uses
  generated catalog baseline files instead), CHANGELOG.md (frozen convention)

Tests: session-lifecycle-state.test.ts (yielded -> paused + no pauseReason
leak on terminals + start clears marker), main-session-restart-recovery.test.ts
(+skip for sessions_yield-paused entries; cleaned-locks variant superseded),
lifecycle.test.ts (+paused transcript-registry-check skips),
session-run-state/reconcile/workboard UI tests (+paused cases).
Verification: 632/632 main-session-recovery suite; 121 lifecycle-state+
lifecycle; 210 UI session-run-state/reconcile/workboard; 487
server-methods/sessions-list/sessions; 922 session utils+message events;
122 chat run-lifecycle; i18n check clean. tsgo core: 5 errors, ALL
pre-existing at HEAD (auth-profiles log + terminal-resolution, recovered
openclaw#57137 stack) — error set byte-identical before/after this change (DIFF=0);
this change adds zero new type errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant