Skip to content

[Bug]: Session embedded-run counter stays pinned after a single ~48k-output-token opus-4-7 turn; subsequent Slack DM inbound silently queued for ~30 min until manual gateway restart (2026.6.1) #90240

Closed as not planned

Description

@redasadki

Summary

After a single very large agent turn on anthropic/claude-opus-4-7 (~48k output tokens, 933k total tokens, 9-minute wall clock), the session's active embedded run counter never decrements; subsequent inbound Slack DMs are silently appended to the session's message log but no new model turn fires for ~30 minutes until a manual openclaw gateway restart.

Steps to reproduce

Observed once on 2026-06-04 in a normal Slack DM session on 2026.6.1. Repro path supported by ~/Library/Logs/openclaw/gateway.log and the session trajectory at <HOME>/.openclaw/agents/main/sessions/<sessionId>.trajectory.jsonl:

  1. Open a Slack DM session on anthropic/claude-opus-4-7 (default model, thinking=medium).
  2. Trigger a turn that produces a single very large assistant payload — in this case, two write tool calls that emitted ~75 KB of markdown each (a spec + an implementation plan), in one turn.
  3. Observed model.completed usage for that turn: {input: 13, output: 48250, cacheRead: 801880, cacheWrite: 83403, total: 933546}, wall clock 09:39:27 → 09:48:29 (GMT+3) = 9 min 2 s. No aborted, no timedOut, no idleTimedOut, no externalAbort, no promptErrorSource. compactionCount: 0.
  4. Send a follow-up inbound on the same Slack DM (a normal small request — e.g., "turn this markdown into slides"). Two subsequent turns at 10:23:10 and 10:23:59 GMT+3 completed normally (~49 s and 14 s).
  5. Send three further inbound messages over the next ~30 minutes:
    • 10:33:30 GMT+3: "confirm which skill and template you will use"
    • 10:54:34 GMT+3: "are you there?"
    • 10:55:04 GMT+3: "did you see this task?"
  6. No model turn fires for any of them until the gateway is manually restarted at 10:48:54 (and then again at 10:50:52). The session's messages list grew from 58 → 60 → 62 → 65 across the silent window (visible in prompt.submitted payloads), confirming inbound was accepted by Slack and queued into the session, but no model.completed event fires until 10:54:43.

At gateway SIGTERM at 10:48:54 the drain banner reports:

[gateway] draining 0 active task(s) and 1 active embedded run(s) before restart with timeout 300000ms

— i.e. the gateway still believed one embedded run was active on this session, even though the last model.completed for it had fired 24 minutes earlier at 10:24:13.

Expected behavior

After a successful model.completed event, the session's active embedded runs counter for that session decrements to zero, so the next inbound message on the same session triggers a new model turn within seconds (as is normal — observed dozens of times in the same session before and after this incident).

Actual behavior

A single very large model.completed event (~48k output tokens / 9-min wall clock) appears to leave the session's active embedded runs counter pinned at 1 even after two subsequent normal turns complete on the same session. Every later inbound on that session is silently queued into the message log without triggering a turn, until the gateway process is restarted. Drain banner at SIGTERM confirms one embedded run was still considered active.

OpenClaw version

2026.6.1 (build 2e08f0f)

Operating system

macOS 26.5.1 (build 25F80), Apple Silicon

Install method

pnpm global (pnpm@openclaw@2026.6.1)

Model

anthropic/claude-opus-4-7 (default model, thinking=medium)

Provider / routing chain

openclaw → anthropic (direct provider, no proxy / gateway / openrouter in between)

Additional provider/model setup details

Default route is openclaw → anthropic; no per-agent override on this session. model: "claude-opus-4-7", modelProvider: "anthropic" in sessions.json. No cloudflare-ai-gateway, no openrouter in this path. No model-side error of any kind in the trajectory.

Logs, screenshots, and evidence

Trajectory excerpt for the Slack DM session (paths and session ids redacted). All times GMT+3:

turn  start     end       dur_s   in_tok   out_tok   cache_read   total     stop     err
#7    09:39:27  09:48:29  542.4   13       48250     801880       933546    null     null   <-- huge turn
#8    10:23:10  10:23:59  49      8        2645      312673       405436    null     null   <-- normal turn after
#9    10:23:59  10:24:13  14      6        121       46362        139089    null     null   <-- normal turn after
        --- 30 min 22 s silence; 3 inbound messages queued, no turns ---
#10   10:54:35  10:54:43  8       6        137       46362        139273    null     null   <-- after manual restart
#11   10:54:58  10:56:01  63      16       2449      1476392      1579483   null     null
#12   10:56:02  10:56:08  7       6        137       46362        149341    null     null

messages array length captured at the start of each prompt during the silent window (from prompt.submitted.data.messages):

10:23:10  messages=52
10:23:59  messages=58   <-- last turn that fired
10:54:36  messages=60   <-- "are you there?" added; no turn ran in between for 2 prior inbound
10:54:58  messages=62
10:56:02  messages=65

model.completed.data for the huge turn (#7) — no error/abort/timeout flags anywhere:

aborted=False idleTimedOut=False timedOut=False
timedOutDuringToolExecution=False externalAbort=False
promptErrorSource=None compactionCount=0
usage={'input': 13, 'output': 48250, 'cacheRead': 801880,
       'cacheWrite': 83403, 'total': 933546}

Gateway log entries during the silent window:

10:23:59  [slack] delivered reply to channel:<channel-id>   (last successful reply)
10:30:00  [cron:<cron-id>] Thinking level "medium" is not supported for anthropic/claude-haiku-4-5-20251001; downgrading to "off".
10:40:00  [cron:<cron-id>] Thinking level "medium" is not supported for anthropic/claude-haiku-4-5-20251001; downgrading to "off".
10:48:54  [gateway] signal SIGTERM received
10:48:54  [gateway] received SIGTERM; restarting
10:48:54  [gateway] draining 0 active task(s) and 1 active embedded run(s) before restart with timeout 300000ms   <-- THE SMOKING GUN
10:49:07  [gateway] loading configuration…
10:49:09  [gateway] agent model: anthropic/claude-opus-4-7 (thinking=medium, fast=off)
10:49:12  [slack] socket mode connected
10:50:52  [gateway] signal SIGTERM received   (second restart, no work in flight)
10:51:09  [slack] socket mode connected
10:54:34  inbound "are you there?" arrives via Slack socket mode → turn fires
10:54:43  [slack] delivered reply to channel:<channel-id>

Notably absent from the silent window:

  • No Slack socket-mode disconnect/reconnect.
  • No error event on the session.
  • No stall-detector / no-output-watchdog firing.
  • No compaction event (compactionCount was 0 throughout).

Impact and severity

  • Affected: Slack DM sessions on anthropic/claude-opus-4-7 that produce a single very large turn (>30k output tokens or >5-min wall clock). Likely reproducible on other channels (WhatsApp, Telegram) using the same session-lane mechanism — not yet verified.
  • Severity: High. Silent outage — user sees their messages delivered to Slack with no error and no reply for ~30 min. No diagnostic surface on either side; only a hand-restart unblocks it.
  • Frequency: Observed once in ~3 weeks of 2026.6.1 use; appears tied to the single-huge-turn pattern, not generic load. Likely intermittent in the wild because few turns hit the size threshold.
  • Consequence: Time-sensitive requests sit unanswered until a human notices and restarts the gateway. In this incident: 30 min 22 s outage, 3 user messages dropped onto the silent queue, ended only by manual restart.

Additional information

This looks like the same root cause family as #54488 ("Session lane starvation: followup drain monopolizes session lane, blocks inbound dispatch for 20-30min") and #84903 ("A single stalled agent session blocks the entire Gateway event loop"), but the trigger here is not a followup-drain backlog or compaction cycle — it's a single oversize successful turn on claude-opus-4-7. Compaction count was 0 the entire time, and the next two turns after the huge one completed normally before the silent window started, so the "stuck active embedded run" counter likely went out of sync only on turn #9's release path, not on turn #7. The actual messages array kept growing as inbound was accepted, so the inbound queue itself works — only the lane release / next-turn dispatch is broken.

Suggested investigation:

  1. Audit the embedded-run release path for the case where a turn finished but a follow-up turn started in the same dispatch window before the release fully propagated.
  2. Verify that clearActiveEmbeddedRun is idempotent and decrements to zero, not by one, since back-to-back turns may double-increment.
  3. Add a periodic reconciliation between active embedded runs and the session's actual current run state, so a stuck counter self-heals within minutes instead of requiring a process restart.

Last known good: previous instances of the same session up to turn #6 (09:24:00) ran for ~2 hours with no issue. First known bad: trajectory file flags none of the abort/timeout/error fields, so the bad state is not surfaced anywhere visible to the agent itself. Workaround: openclaw gateway restart clears it.

Related issues: #54488, #84903, #85532, #87397, #88870.

Activity

  1. clawsweeper commented on Jun 4, 2026

    @clawsweeper
    Contributor

    Codex review: this still needs some work.

    Summary
    Keep this issue open: independent reports establish silent session stalls on official releases, and neither a verified fix nor an exact canonical replacement resolves the reported lifecycle failure.

    Reproducibility: no. high-confidence current-main reproduction is established; the release reports are concrete, but source inspection does not prove their proposed ownership-leak mechanism.

    Maintainer decision needed

    • Question: Should investigation first capture the retained owner in a current-version stall, or attempt a deterministic settlement regression from the existing traces?
    • Recommendation: Capture the retained owner: Correlate runner, reply-operation, lane, and diagnostic ownership during a current-version stall before choosing a repair.
    • Why: The reports establish meaningful failures, but current source and the abandoned mitigation do not establish the production transition that leaks ownership.

    Next step
    Identify the retained lifecycle owner in a current-version stall and establish a failing completion-to-next-inbound regression before selecting a focused repair.

    Review details

    Best possible solution:

    Release completed work through its lifecycle owner and resume queued input while preserving genuinely active successor runs.

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

    No high-confidence current-main reproduction is established; the release reports are concrete, but source inspection does not prove their proposed ownership-leak mechanism.

    Is this the best way to solve the issue?

    Repairing the proven lifecycle owner is preferable to unconditional reconciliation, which could clear a valid successor or abort legitimate long-running work.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The large-output trigger and handle-mismatch explanation remain hypotheses; two normal turns completed after the original large turn.
    • The reports do not identify the exact retained runtime owner on current main, and the Feishu child-completion trigger may represent a distinct lifecycle path.

    Codex review notes: model internal, reasoning medium; reviewed against 204ff9770617.

    Label changes

    Label changes:

    No label changes.

    Label justifications:

    • P1: Independent official-release reports describe prolonged silent interruption of active channel conversations requiring a Gateway restart.
    • impact:session-state: The reported blockage concerns retained session work ownership after apparent completion.
    • impact:message-loss: Accepted inbound messages remain unanswered while the affected conversation is stalled.
    Evidence reviewed

    Acceptance criteria:

    • Establish a failing completion-to-next-inbound regression through the production runner and session admission boundary.
    • Verify repeated cleanup remains idempotent and stale cleanup preserves a live successor.
    • Verify failed child completion does not strand requester input, if that trigger reproduces.
    • After identifying the repair boundary, run its touched tests and targeted typecheck, lint, and format checks.

    What I checked:

    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; those execution lanes are retired.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

    Reviewed October 15, 2026, 10:37 PM ET / October 16, 2026, 02:37 UTC.

  2. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    on Jun 4, 2026
  3. added
    clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.
    on Jun 15, 2026
  4. ryanbush101 commented on Jun 15, 2026

    @ryanbush101

    I hit what looks like the same class of issue today on OpenClaw 2026.6.6 (8c802aa) with a Slack DM session.

    Environment:

    • macOS on Mac mini
    • OpenClaw package install via npm/Homebrew path
    • Gateway model: openai/gpt-5.5 with Codex embedded runner available
    • Slack Socket Mode DM

    User-visible symptom:

    • Sending two Slack DM messages back-to-back causes the bot to appear dead.
    • The second inbound message queues behind the first stuck run.
    • Manual openclaw gateway restart / OpenClaw restart clears it and replies resume.

    Relevant redacted log sequence from /tmp/openclaw/openclaw-2026-06-15.log:

    stalled session: sessionId=<redacted> sessionKey=agent:main:slack:direct:<redacted> state=processing age=245s queueDepth=1 reason=active_work_without_progress classification=stalled_agent_run activeWorkKind=embedded_run lastProgress=embedded_run:started lastProgressAge=8238s recovery=none
    
    stalled session: sessionId=<redacted> sessionKey=agent:main:slack:direct:<redacted> state=processing age=141s queueDepth=2 reason=active_work_without_progress classification=stalled_agent_run activeWorkKind=embedded_run lastProgress=embedded_run:recovery_skipped_active_owner lastProgressAge=270s recovery=none
    
    stuck session recovery: sessionId=<redacted> sessionKey=agent:main:slack:direct:<redacted> age=365s action=abort_embedded_run aborted=true drained=true released=0
    
    stuck session recovery outcome: status=aborted action=abort_embedded_run sessionId=<redacted> sessionKey=agent:main:slack:direct:<redacted> activeWorkKind=embedded_run lane=session:agent:main:slack:direct:<redacted> aborted=true drained=true forceCleared=false released=0
    

    Later repeated around the same Slack DM lane:

    stuck session recovery reclaiming stale active reply work: sessionId=<redacted> sessionKey=agent:main:slack:direct:<redacted> age=360s queueDepth=1 activeSessionId=<redacted>
    
    stuck session recovery: sessionId=<redacted> sessionKey=agent:main:slack:direct:<redacted> age=360s action=abort_embedded_run aborted=true drained=true released=0
    
    stuck session recovery outcome: status=aborted action=abort_embedded_run sessionId=<redacted> sessionKey=agent:main:slack:direct:<redacted> activeWorkKind=embedded_run lane=session:agent:main:slack:direct:<redacted> aborted=true drained=true forceCleared=false released=0
    

    One possible confounder: the same install had repeated state migration warnings before I repaired plugin state:

    Legacy state migration warnings:
    - Left plugin install index in place because shared SQLite state has conflicting plugin install metadata for: codex, slack
    

    I repaired that separately by backing up state, moving the legacy /Users/bane/.openclaw/plugins/installs.json out of the live path, and running openclaw plugins registry --refresh. After that:

    openclaw plugins doctor
    No plugin issues detected.
    

    So the stale plugin metadata may have contributed, but the session behavior itself matches this issue: active embedded run remains pinned/stale, queued Slack DM inbound does not recover cleanly, and restart is the practical recovery path.

  5. removed
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.
    on Jul 30, 2026
  6. 13 remaining items

  7. guanbear commented on Aug 28, 2026

    @guanbear
    Contributor

    We observed the same failure class on a Feishu direct-message session running OpenClaw 2026.7.1 in a Linux container. This adds a second channel and a newer release to the evidence here.

    Observed sequence

    1. A child task had already reached a terminal killed state.
    2. Its completion/announce path remained attached to the requester session. Logs included:
    Active requester session could not be woken ... queue_message_failed reason=no_active_run
    Subagent completion direct announce failed ... completion agent did not use the message tool for message-tool-only delivery
    
    1. Subsequent inbound DM messages were appended to the original session transcript, but no reply was delivered.
    2. Diagnostics repeatedly classified the session as stalled while declining recovery:
    classification=stalled_agent_run activeWorkKind=embedded_run ... recovery=none
    
    1. The session remained blocked for more than ten minutes. The child was no longer active, but the gateway still reported active embedded work for the requester.
    2. A gateway process restart cleared the orphaned runtime state and restored the same DM session; no transcript reset or new session was required.

    Additional isolation

    • Gateway health and the Feishu WebSocket were healthy throughout.
    • Direct outbound delivery through openclaw message send succeeded while inbound turns for this one session remained blocked.
    • Other sessions on the same gateway continued to work.
    • The affected session had earlier seen a child-completion announce failure, which may be a trigger for the pinned embedded-run state.

    This appears consistent with the counter/lifecycle leak described in this issue rather than a channel transport failure. The strongest invariant for a regression test would be: once child work reaches a terminal state, requester-session embedded-run accounting must eventually return to zero even when completion announce/wake fails.

  8. added
    clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.
    issue-rating: 🦐 gold shrimpDecent issue quality, but reproduction details are still incomplete.
    and removed
    issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.
    on Aug 29, 2026
  9. openclaw-barnacle commented on Sep 21, 2026

    @openclaw-barnacle

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  10. added
    issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.
    and removed
    issue-rating: 🦐 gold shrimpDecent issue quality, but reproduction details are still incomplete.
    on Oct 10, 2026
  11. steipete commented on Oct 24, 2026

    @steipete
    Contributor

    Thanks for filing this. We're closing older issues that no longer look actionable on current main.

    We couldn't confirm a leaked run counter on current main, and the reports are from 2026.6.1 and 2026.7.1. If a session still stops processing inbound messages until restart on a current release, please open a fresh issue with the diagnostic output captured during the stall.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions