Skip to content

fix: recover terminal session status on visible inbound turns - #89045

Merged
vincentkoc merged 8 commits into
openclaw:mainfrom
Jerry-Xin:fix/86827-failed-session-silent-drop
Jun 28, 2026
Merged

vincentkoc merged 8 commits into
openclaw:mainfrom
Jerry-Xin:fix/86827-failed-session-silent-drop

Conversation

@Jerry-Xin

@Jerry-Xin Jerry-Xin commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #86827 — group chat sessions stuck in failed status silently drop all subsequent messages.

When a group chat session enters a terminal status (failed, timeout, or killed), the reply dispatch path returns a successful no-op (queuedFinal: false, zero dispatch counts) without starting an AI turn or delivering any user-visible error. All subsequent messages are silently discarded until a manual /new reset.

Root Cause

Three independent mechanisms conspire to create the silent drop:

  1. Session state persistence: initSessionState() reuses the existing session entry with its terminal status field intact, passing it downstream unchanged.
  2. Reply operation locking: A stale ReplyOperation from the failed run remains registered in replyRunRegistry, causing admitReplyTurn() to return skipped with reason active-run.
  3. No fallback or diagnostic: The skipped admission produces a valid dispatch result with zero counts, and no warning is logged — the message simply vanishes.

Changes

1. Auto-recover terminal sessions (session.ts)

When a visible (non-cron/heartbeat) inbound message hits a session with recoverable terminal status, automatically clear the stale lifecycle fields (status, startedAt, endedAt, runtimeMs, abortedLastRun) while preserving the sessionId and transcript continuity — no session rotation.

2. Clear stale reply operations with race guard (dispatch-from-config.ts)

When admitReplyTurn() returns skipped with reason active-run but the persisted session is in terminal status, force-clear the stale reply operation via forceClearReplyRunBySessionId() and retry admission once. This breaks the deadlock without risking infinite retry loops.

Concurrent recovery guard: After a recovery turn clears the proven stale leftover and admits its own fresh operation, it is marked with a terminalRecovery flag. If a second visible message arrives against the same terminal snapshot before the first recovery clears the store state, the force-clear branch now skips operations marked as in-flight terminal recoveries. This prevents a sibling recovery turn from killing a fresh recovery that is already in flight, letting concurrent turns fall through to normal busy/wait handling instead.

3. Agent API path (agent.ts)

Mirror the same terminal recovery logic in the agent API dispatch path so agent API requests also clear terminal state for visible requests.

4. Diagnostics (kernel.ts, types.ts)

Add a structured warning log when a visible channel turn dispatch completes with queuedFinal: false and zero tool/block/final counts — a sentinel for future silent message drops. Excludes system turns (heartbeat/cron/exec) and observe-only admissions.

Real behavior proof

Captured by driving the real runtime modules (dispatchReplyFromConfig, initSessionState, reply-run-registry) with verbose logging on, no vitest and no module mocks — only the production parameters the Gateway supplies plus a real on-disk JSON session store. A before/after contrast was produced by running the identical driver in a pre-fix worktree.

  • Behavior or issue addressed: A group-chat session left in a terminal lifecycle status (failed/timeout/killed) silently drops every later message — the stale lifecycle entry plus a leftover "active" reply operation block turn admission, so a subsequent visible inbound message gets no AI turn and no reply (Group chat session stuck in 'failed' state silently drops all subsequent messages #86827).
  • Real environment tested: Compiled branch source at HEAD ac52eb0b24; macOS 15.3.1 (Darwin 24.3.0, arm64), Node v24.10.0. Product built with pnpm build:docker (exit 0); the recovery log string is present in compiled dist/. Evidence captured via tsx driving the real in-process dispatch/session/registry path. Before/after contrast run at pre-fix commit 8de37e1ce4 (parent of the first PR commit).
  • Failing proof before fix (8de37e1ce4, identical driver + input): real dispatchReplyFromConfig() for a visible group turn on a status="failed" session with a stale running reply op —
    [dispatch] registered stale running reply op; isActive=true
    [dispatch] calling REAL dispatchReplyFromConfig() for visible group turn on terminal session ...
    [dispatch] dispatch TIMED-OUT (no reply within 8s): visible turn stuck behind the stale terminal reply op -> SILENT DROP
    [dispatch] stale op result after dispatch = null
    [dispatch] registry isActive after dispatch = true
    
    And real initSessionState() against an on-disk store: RESULT: STILL-TERMINAL — session entry remains status=failed after a visible inbound turn.
  • Exact steps or command run after this patch:
    NODE_OPTIONS=--max-old-space-size=8192 pnpm build:docker
    export OPENCLAW_HOME=$(mktemp -d) OPENCLAW_DISABLE_BUNDLED_PLUGINS=1 \
           OPENCLAW_SKIP_CHANNELS=1 OPENCLAW_SKIP_PROVIDERS=1 OPENCLAW_SKIP_CRON=1
    node_modules/.bin/tsx ./_dispatch_driver.mts   # drives real dispatchReplyFromConfig()
    node_modules/.bin/tsx ./_proof_driver.mts      # drives real initSessionState() + registry
    
    The driver seeds a real session store with a terminal failed group entry, registers a real stale running reply operation, then calls the real dispatchReplyFromConfig() for a visible inbound group message.
  • Evidence after fix (ac52eb0b24): copied live console output from running the real in-process driver node_modules/.bin/tsx ./_dispatch_driver.mts (drives the production dispatchReplyFromConfig()); redacted runtime log:
    [dispatch] registered stale running reply op; isActive=true
    [dispatch] calling REAL dispatchReplyFromConfig() for visible group turn on terminal session ...
    dispatch-from-config: cleared stale active reply operation for terminal session agent:main:telegram:group:<redacted>
    [dispatch] dispatch returned: {"queuedFinal":true,"counts":{"tool":0,"block":0,"final":1}}
    [dispatch] stale op result after dispatch = {"kind":"failed","code":"run_failed"}
    [dispatch] registry isActive after dispatch = false
    
    Real session lifecycle: initSessionState -> isNewSession=false sessionId=<same> abortedLastRun=false, and AFTER turn -> status=undefined ... RESULT: RECOVERED — terminal lifecycle cleared, same sessionId reused (transcript preserved).
  • Observed result after fix: A visible inbound message to a terminal session (1) emits the new recovery log, (2) force-fails the stale leftover op and frees the registry (isActive=false), (3) produces a real queued reply (queuedFinal:true, counts.final:1) instead of the pre-fix zero-count silent drop / indefinite block, and (4) clears the persisted terminal lifecycle fields while reusing the same sessionId (transcript preserved). The pre-fix checkout, given identical input, leaves the session failed and the turn stuck/dropped.
  • What was not tested: The full Docker image build failed at the pnpm install --frozen-lockfile layer due to transient npm-registry CDN errors fetching optional native packages (network, not OOM and not code), so no end-to-end live channel socket round-trip was performed; the proof drives the real in-process dispatch/session/registry runtime that a channel turn funnels into. The agent.ts Gateway RPC path and the kernel.ts zero-count warning were source-verified but not separately runtime-exercised here. Concurrency races (sibling visible-turn recovery, heartbeat non-clobber) are covered by the added unit tests. Architecture: arm64 (macOS) only; CI truth is Linux x64 Node 24.

Tests

  • session.test.ts: Verify failed group sessions recover without rotating the transcript
  • dispatch-from-config.test.ts: Verify stale active reply operations are cleared for terminal sessions and admission is retried; verify two concurrent visible turns against the same terminal snapshot do not kill each other's recovery operations
  • agent.test.ts: Verify terminal failed agent API sessions recover without session rotation; updated existing failed-session tests to verify terminal state clearing
  • kernel.test.ts: Verify zero-count visible dispatch warning is emitted
  • agent-runner-execution.test.ts / agent-runner-memory.test.ts: Updated mock ReplyOperation stubs with new terminalRecovery field and markTerminalRecovery method

All focused tests pass across 2 Vitest shards (512 cases).

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 1, 2026
@clawsweeper

clawsweeper Bot commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 28, 2026, 6:22 PM ET / 22:22 UTC.

Summary
The branch clears terminal lifecycle state on visible turn session reuse, force-clears stale same-session reply operations with a terminalRecovery guard, emits zero-count visible-dispatch warnings, and adds regression tests.

PR surface: Source +176, Tests +588. Total +764 across 12 files.

Reproducibility: yes. The linked issue includes live Octo evidence, current main source still reuses terminal session state and busy admission paths, and the PR body provides before/after production-module driver output; I did not run a fresh live transport repro in this read-only pass.

Review metrics: 1 noteworthy metric.

  • Persisted Lifecycle Fields Cleared: 5 cleared in place. The PR clears status, startedAt, endedAt, runtimeMs, and abortedLastRun during visible terminal-session recovery, which is the central upgrade-sensitive state change.

Stored data model
Persistent data-model change detected: serialized state: src/auto-reply/reply/session.test.ts, serialized state: src/auto-reply/reply/session.ts, unknown-data-model-change: src/auto-reply/reply/session.test.ts, unknown-data-model-change: src/auto-reply/reply/session.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #86827
Summary: This PR is the open closing implementation candidate for the canonical terminal group-session silent-drop issue; adjacent failed-session and active-run reports overlap but do not replace this fix path.

Members:

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

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Mantis proof suggestion
A live Telegram group transcript would materially prove that a post-failure visible mention now produces a reply rather than silently disappearing. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram live: verify a visible group mention after a failed or timed-out session starts a new reply instead of silently dropping.

Risk before merge

  • [P1] The PR intentionally changes persisted recovery semantics by clearing terminal lifecycle fields in place while preserving the same session id and transcript continuity.
  • [P1] The force-clear and terminalRecovery admission guard are message-delivery critical; a regression could leave visible turns stuck behind stale operations or cancel a valid recovery reply.
  • [P1] The supplied proof is strong for production modules in process, but maintainers may still want a live Telegram or Octo group-channel round trip before landing.

Maintainer options:

  1. Accept In-Place Recovery (recommended)
    Maintain this PR's policy of preserving session id and transcript continuity while clearing terminal lifecycle fields on visible recovery turns.
  2. Require Live Transport Proof
    Ask for a Telegram or Octo group-channel round trip showing a post-terminal visible mention now produces a reply instead of silently disappearing.
  3. Choose A Different Recovery Policy
    Pause this PR if maintainers prefer session rotation, unbinding, or a visible user error over clearing terminal state in place.

Next step before merge

  • [P2] Remaining action is maintainer acceptance of the recovery policy and optional live transport proof, not a narrow automated repair.

Security
Cleared: No concrete security or supply-chain concern was found; the diff changes TypeScript runtime and tests without workflows, dependencies, package resolution, secrets, or external execution paths.

Review details

Best possible solution:

Land or replace the shared core recovery policy after maintainers accept in-place terminal-session recovery semantics and decide whether transport-level proof is required.

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

Yes. The linked issue includes live Octo evidence, current main source still reuses terminal session state and busy admission paths, and the PR body provides before/after production-module driver output; I did not run a fresh live transport repro in this read-only pass.

Is this the best way to solve the issue?

Yes as an implementation direction, pending maintainer policy acceptance. The patch fixes shared session and reply-operation paths rather than adding a channel-specific workaround; rotation or visible-error behavior remains the policy alternative.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P1: The linked workflow can silently drop real group-channel messages after a failed or timed-out session.
  • merge-risk: 🚨 session-state: The PR changes how persisted failed, timeout, and killed session lifecycle state is recovered while keeping the same session id.
  • merge-risk: 🚨 message-delivery: The PR changes active reply-operation admission and force-clear behavior on visible turns, directly affecting whether replies are dropped or delivered.
  • 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. Sufficient (live_output): The PR body includes after-fix copied live output from real in-process runtime modules with an on-disk session store plus a pre-fix contrast; live transport proof remains optional maintainer evidence rather than a contributor proof gate.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix copied live output from real in-process runtime modules with an on-disk session store plus a pre-fix contrast; live transport proof remains optional maintainer evidence rather than a contributor proof gate.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The shared channel fix affects visible Telegram group reply delivery and can be demonstrated with a short Telegram proof if maintainers want transport-level evidence.
Evidence reviewed

PR surface:

Source +176, Tests +588. Total +764 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 6 200 24 +176
Tests 6 593 5 +588
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 793 29 +764

What I checked:

  • Repository policy applied: Root and scoped policy were read fully; the relevant guidance treats session state, channel delivery, fallback behavior, and Gateway paths as compatibility-sensitive review surfaces. (AGENTS.md:35, a54206f0f5d1)
  • Current main still reuses terminal session entries: Current main computes freshEntry from freshness and then reuses entry.sessionId and lifecycle fields directly; there is no recoverable failed/timeout/killed cleanup helper on this path. (src/auto-reply/reply/session.ts:541, a54206f0f5d1)
  • Current main lacks terminal-specific active-run recovery: Current main returns busy after skipped active-run admission and lacks the PR's terminal-session force-clear plus retry path. (src/auto-reply/reply/dispatch-from-config.ts:1424, a54206f0f5d1)
  • PR recovers terminal lifecycle fields in place: The branch adds failed/timeout/killed detection, builds a recovered entry, preserves the session id, and clears status, startedAt, endedAt, runtimeMs, and abortedLastRun for visible terminal-session reuse. (src/auto-reply/reply/session.ts:163, c0b56f9ca65a)
  • PR guards stale-operation recovery: The branch force-clears only visible same-session terminal leftovers, skips in-flight terminalRecovery operations, and marks newly admitted recovery operations at the shared admission point. (src/auto-reply/reply/dispatch-from-config.ts:1428, c0b56f9ca65a)
  • PR adds operation state for the race guard: ReplyOperation gains terminalRecovery and markTerminalRecovery so concurrent visible turns can distinguish a stale leftover from a fresh recovery in flight. (src/auto-reply/reply/reply-run-registry.ts:59, c0b56f9ca65a)

Likely related people:

  • jalehman: Recent current-main history includes guarded reply session initialization, lifecycle storage seams, and central turn-admission work in the same session and reply-dispatch area. (role: session lifecycle and reply ownership contributor; confidence: high; commits: 95e37f8e9517, 49e6f5a524bc, 62b51a6295ee; files: src/auto-reply/reply/session.ts, src/auto-reply/reply/dispatch-from-config.ts)
  • joshavant: Recent current-main history directly changed active implicit session rollover behavior in the session reuse path this PR modifies. (role: recent session rollover contributor; confidence: medium; commits: 6f1076351cbe; files: src/auto-reply/reply/session.ts)
  • vincentkoc: Recent current-main history touches dispatch semantics, channel delivery, and Gateway session-change plumbing adjacent to the affected message-delivery path. (role: recent channel and dispatch area contributor; confidence: medium; commits: 9e8ab083dd6b, 5571c786d3df, eb9318e9535a; files: src/auto-reply/reply/dispatch-from-config.ts, src/channels/turn/kernel.ts, src/gateway/server-methods/agent.ts)
  • steipete: Current-main history shows major channel turn refactors and core dispatch routing work that own the shared channel boundary this PR affects. (role: channel core and dispatch architecture contributor; confidence: medium; commits: 1507a9701b83, 797bcd5bdb28, 6c3740255f3a; files: src/channels/turn/kernel.ts, src/channels/message/inbound-reply-dispatch.ts, src/auto-reply/reply/dispatch-from-config.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jun 1, 2026
@Jerry-Xin
Jerry-Xin force-pushed the fix/86827-failed-session-silent-drop branch 2 times, most recently from 6503187 to 3fa658b Compare June 1, 2026 18:07
@Jerry-Xin

Copy link
Copy Markdown
Contributor Author

Rebased on latest upstream/main (965e680, clean rebase, no conflicts).

@Jerry-Xin
Jerry-Xin force-pushed the fix/86827-failed-session-silent-drop branch from 3fa658b to 9c8ec76 Compare June 1, 2026 22:06
@Jerry-Xin

Copy link
Copy Markdown
Contributor Author

Rebased on latest upstream/main (646df2d, clean rebase, no conflicts).

@Jerry-Xin
Jerry-Xin force-pushed the fix/86827-failed-session-silent-drop branch from 9c8ec76 to 03149fb Compare June 2, 2026 00:06
@Jerry-Xin

Copy link
Copy Markdown
Contributor Author

Rebased on latest upstream/main (8a9acd2, clean rebase, no conflicts).

@Jerry-Xin
Jerry-Xin force-pushed the fix/86827-failed-session-silent-drop branch from 03149fb to 68668af Compare June 2, 2026 02:07
@Jerry-Xin

Copy link
Copy Markdown
Contributor Author

Rebased on latest upstream/main (57ea5af, clean rebase, no conflicts).

@Jerry-Xin
Jerry-Xin force-pushed the fix/86827-failed-session-silent-drop branch from 68668af to fd71257 Compare June 2, 2026 04:07
@Jerry-Xin

Copy link
Copy Markdown
Contributor Author

Rebased on latest upstream/main (ffbd02f, clean rebase, no conflicts).

@Jerry-Xin
Jerry-Xin force-pushed the fix/86827-failed-session-silent-drop branch from fd71257 to ac79b73 Compare June 2, 2026 06:07
@Jerry-Xin

Copy link
Copy Markdown
Contributor Author

Rebased on latest upstream/main (85d2dd8). Resolved import conflict in src/auto-reply/reply/dispatch-from-config.ts — merged upstream's new DispatcherOutcomeCountsView/readDispatcherFailedCounts imports with our forceClearReplyRunBySessionId import. All changes preserved.

@Jerry-Xin

Copy link
Copy Markdown
Contributor Author

Real behavior proof

  • Behavior or issue addressed: Two visible group-chat messages arriving against the same terminal (failed) session snapshot could race: the second turn force-clears the first turn's freshly admitted recovery operation, dropping the first message — the exact silent-loss path this PR fixes.
  • Real environment tested: Local patched OpenClaw checkout at b2b7996945, macOS arm64, Node.js v24.10.0.
  • Failing proof before fix: The two-turn race regression test (does not kill a sibling recovery turn when a second visible turn races the same terminal snapshot) was authored as part of this PR and does not exist on upstream/main. When run against the original commit (ac79b730a1) without the guard fix, the second turn force-fails the first recovery operation (the terminalRecovery guard did not exist).
  • Exact steps or command run after this patch:
    node scripts/run-vitest.mjs \
      src/auto-reply/reply/dispatch-from-config.test.ts \
      src/auto-reply/reply/session.test.ts \
      src/channels/turn/kernel.test.ts \
      src/auto-reply/reply/agent-runner-execution.test.ts \
      src/auto-reply/reply/agent-runner-memory.test.ts
    
  • Evidence after fix:
    [test] starting test/vitest/vitest.auto-reply.config.ts
     ✓ auto-reply src/auto-reply/reply/agent-runner-execution.test.ts (155 tests) 582ms
     ✓ auto-reply src/auto-reply/reply/session.test.ts (97 tests) 288ms
     ✓ auto-reply src/auto-reply/reply/agent-runner-memory.test.ts (40 tests) 217ms
     ✓ auto-reply src/auto-reply/reply/dispatch-from-config.test.ts (191 tests) 6650ms
     Test Files  4 passed (4)
          Tests  483 passed (483)
    
    [test] starting test/vitest/vitest.channels.config.ts
     ✓ channels src/channels/turn/kernel.test.ts (29 tests) 16ms
     Test Files  1 passed (1)
          Tests  29 passed (29)
    
    [test] passed 2 Vitest shards in 15.52s
    
  • Observed result after fix: All 512 tests pass across 2 Vitest shards, including the new two-turn concurrent recovery race regression test. The terminalRecovery flag prevents the second visible turn from force-clearing the first turn's in-flight recovery operation; both turns produce replies without message loss.
  • What was not tested: No live channel (Telegram/Octo/Discord) end-to-end test was performed. The race condition is validated through focused Vitest integration tests that simulate concurrent visible inbound dispatches against shared terminal session state. The fix is channel-generic and does not depend on any channel-specific behavior.

@openclaw-barnacle openclaw-barnacle Bot added triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 2, 2026
@Jerry-Xin
Jerry-Xin force-pushed the fix/86827-failed-session-silent-drop branch from b2b7996 to bc38886 Compare June 2, 2026 12:00
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jun 2, 2026
@Jerry-Xin

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest upstream/main and pushed (new head 1a6fa03a3d, clean rebase, 8 commits replayed, no conflicts). Requesting a fresh review against the current head.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@Jerry-Xin

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest upstream/main and pushed (new head 2af8d39400, clean rebase, 8 commits replayed, no conflicts). Requesting a fresh review against the current head.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@Jerry-Xin

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest upstream/main and pushed (new head 415c3d4302, clean rebase, 8 commits replayed, no conflicts). Requesting a fresh review against the current head.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@Jerry-Xin

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Rebased onto the latest upstream/main and pushed (new head 1baf08131c, clean rebase, 8 commits replayed, no conflicts). Requesting a fresh review against the current head.

@clawsweeper

clawsweeper Bot commented Jun 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@Jerry-Xin

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Rebased onto the latest upstream/main and pushed (new head 5e3547e4e0, clean rebase, 8 commits replayed, no conflicts). Requesting a fresh review against the current head.

@clawsweeper

clawsweeper Bot commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@Jerry-Xin

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Rebased onto the latest upstream/main and pushed (new head d9fc37ec47, clean rebase, 8 commits replayed, no conflicts). Requesting a fresh review against the current head.

@clawsweeper

clawsweeper Bot commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@Jerry-Xin

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Rebased onto the latest upstream/main and pushed (new head cc73d465cd, clean rebase, 8 commits replayed, no conflicts). Requesting a fresh review against the current head.

@clawsweeper

clawsweeper Bot commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@Jerry-Xin

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Rebased onto the latest upstream/main and pushed (new head 66942e3d7d, clean rebase, 8 commits replayed, no conflicts). Requesting a fresh review against the current head.

@clawsweeper

clawsweeper Bot commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

忻役 and others added 8 commits June 29, 2026 06:11
…aw#86827)

When a group chat session enters a terminal status (failed/timeout/killed),
subsequent visible inbound messages now automatically recover the session by
clearing stale lifecycle fields while preserving the session ID and transcript
continuity.

Changes:
- session.ts: detect terminal status on visible turns and clear status/
  startedAt/endedAt/runtimeMs/abortedLastRun without rotating sessionId
- dispatch-from-config.ts: force-clear stale active reply operations for
  terminal sessions and retry admission once
- agent.ts: mirror terminal recovery in the agent API dispatch path
- kernel.ts: add zero-count visible dispatch warning diagnostic
- types.ts: add 'warning' to ChannelTurnLogEvent event union
When two visible messages arrive against the same terminal session
snapshot, the second turn could force-fail the first turn's freshly
admitted recovery operation, dropping the very message the recovery
path exists to save.

Add a terminalRecovery flag on ReplyOperation that is set after a
recovery turn clears the proven stale leftover and admits its own
operation. The force-clear branch now skips operations marked as
in-flight terminal recoveries, letting concurrent turns fall through
to normal busy/wait handling instead.

Add a two-turn regression test that gates the first recovery turn
open, races a second visible turn against the same terminal snapshot,
and asserts neither turn's operation is incorrectly killed.

Also fix missing FinalizedMsgContext import in kernel.ts.
A heartbeat/control turn can pass the early active-run short-circuit, reach
the terminal force-clear branch, and abort an in-flight visible recovery
operation that a concurrent visible turn just admitted (before that op is
marked terminalRecovery). Gate the force-clear to visible reply turns so
non-visible turns fall through to normal busy/skip handling instead of
killing the recovery they are meant to protect.

Adds a focused regression test exercising a heartbeat turn that reaches the
force-clear branch against a terminal session snapshot with an active
recovery operation present; it must leave that operation intact and skip.
…ble turn

The same-session terminal-recovery race could still drop a reply when two
visible turns raced the same failed snapshot. The terminalRecovery marker was
set only on the post-force-clear re-admission path, never on the clean no-stale
admission path. So when the first turn admitted cleanly (no stale op to clear),
its recovery op stayed terminalRecovery=false and a second concurrent visible
turn force-cleared it, dropping the first reply (openclaw#86827).

Consolidate marking to the single owned-admission choke point that both the
clean no-stale admission and the re-admission-after-force-clear flow through.
Genuine stale leftovers from the original failed run never pass through this
admission, so they stay unmarked and remain force-clearable.

Add a no-stale regression twin to the existing stale-race test.
…ry turns

maybeWarnZeroCountVisibleDispatch re-implemented a partial visibility
check that omitted observedReplyDelivery, so visible turns delivered via
the observed-delivery path (queuedFinal=false, zero counts,
observedReplyDelivery=true) falsely tripped the silent-drop sentinel and
emitted a bogus zero-count-visible-dispatch warning/event.

Use the canonical hasVisibleChannelTurnDispatch helper for the warning
suppression so all non-count delivery paths (observedReplyDelivery,
fallback, summary, queuedFinal) are honored. Add regression tests
covering the observed-delivery case (no warning) and a genuinely empty
visible dispatch (still warns).
@Jerry-Xin

Copy link
Copy Markdown
Contributor Author

Rebased onto latest upstream/main (a54206f) — clean replay of 8 commits, no conflicts, no diff changes. New head c0b56f9. @clawsweeper re-review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. 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.

Group chat session stuck in 'failed' state silently drops all subsequent messages

2 participants