Repository navigation
Closed
Labels
P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.clawsweeper-recovery-stuckclawsweeper:not-repro-on-mainClawSweeper found high-confidence evidence that this issue no longer reproduces on main.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.impact:ux-release-blockerA non-technical user is blocked without terminal, logs, config, or support.issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.
Description
Bug type
Behavior bug — session state corruption after provider failure, blocking new session creation
Environment
- OpenClaw v2026.6.11 (e085fa1)
- macOS (darwin arm64)
- Node 24.8.2
- Model:
minimax-portal/MiniMax-M3(viaapi.minimaxi.com) - Channel: Feishu (direct DM)
Summary
When a third-party model provider returns 503 errors or times out, the session enters a corrupted state (unknown/1049k (?%) token count) that permanently blocks new messages on the same session key. The gateway does not automatically recover, and the session state prevents new session creation — requiring manual deletion of session files.
Steps to reproduce
- Configure a Feishu channel with a model backed by a flaky provider (e.g.,
minimax-portal/MiniMax-M3) - Send a message that triggers a model call
- Provider returns 503 "server is busy" or hangs for 120s+
- Gateway logs show
stalled session,active_work_without_progress,per-chat task exceeded 300000ms cap - Session state becomes
unknown/1049k (?%)inopenclaw sessionsoutput - Send another message to the same session key
Expected behavior
- Session should either:
- Retry with fallback model (if configured)
- Clean up stale session state after timeout
- Create a new session when the existing one is dead
- Token count should not become "unknown" — at minimum show "stale" or "error"
Actual behavior
- Session state corrupted to
unknown/1049k (?%) - No active Claude process for the session
- New messages dispatched to the dead session, never processed
- No automatic recovery — requires manual deletion of session file +
sessions.jsonentry - All subsequent messages to the same session key are silently dropped
Logs
[diagnostic] long-running session: sessionId=... state=processing age=137s queueDepth=1 reason=active_model_call_without_prog
[diagnostic] stalled session: ... state=processing age=252s reason=active_work_without_progress classification=stalled_agent_run
[diagnostic] per-chat task exceeded 300000ms cap; evicting from queue so later same-key messages can proceed
After eviction, session remains in store with unknown token count. New messages find the existing session entry and try to resume it, but no process is running to handle them.
Workaround
Manual cleanup:
# 1. Delete session file
rm ~/.openclaw/agents/claude/sessions/<session-id>.jsonl
# 2. Remove from sessions.json
python3 -c "
import json
path = '~/.openclaw/agents/claude/sessions/sessions.json'
with open(path) as f: data = json.load(f)
del data['<session-key>']
with open(path, 'w') as f: json.dump(data, f, indent=2)
"Related issues
- user-switched model has no fallback chain, causing session deadlock on provider outage #84865 — user-switched model has no fallback chain, causing session deadlock on provider outage
- Cron jobs stall during AI model calls (model_call:stream_progress never completes) #91892 — Cron jobs stall during AI model calls
- [Bug]: Codex native compaction can leave post-compaction context usage stale or unknown #66263 — Codex native compaction can leave post-compaction context usage stale or unknown
- Stuck-session recovery abort surfaces nothing to the user (surface_error with reason=none + draft deletion), and in-flight tool promises complete into a dead run #103905 — Stuck-session recovery abort surfaces nothing to the user
Impact
This affects any session backed by an unreliable provider. In our case:
- 10+ sessions stuck in
unknownstate (all MiniMax-M3) - Multiple Feishu users affected (third, fourth, fifth accounts)
- Cron jobs silently failing
- No user-visible error — messages just disappear
Suggested fix
- Session timeout cleanup: When
per-chat task exceeded 300000ms capfires, also clean up the session state insessions.json(set to "dead" or remove) - Dead session detection: Before dispatching to an existing session, check if there's an active process; if not, create a new session
- Token count resilience: Never show "unknown" — show "stale", "error", or "0" instead
- Provider fallback for all sessions: Even if the model was user-selected, have a fallback for 503/timeout scenarios
Reacted by clawsweeper
Reacted by Sophia_Amadeus and clawsweeper
Metadata
Metadata
Assignees
Labels
P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.clawsweeper-recovery-stuckclawsweeper:not-repro-on-mainClawSweeper found high-confidence evidence that this issue no longer reproduces on main.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.impact:ux-release-blockerA non-technical user is blocked without terminal, logs, config, or support.issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.
Type
Fields
Priority
None yet
Activity
clawsweeper commentedon Jul 16, 2026
Thanks for the context here. I did a careful shell check against current
main, and this is already implemented.Close as implemented: current main turns a force-cleared stalled run into a terminal session state and re-admits the next visible message, removing the reported permanent same-key block. Automatic fallback for a user-selected model and unknown token display are distinct tracked concerns.
I found the merged PR that appears to have closed this: #112166: fix(agents): persist terminal session state after force-clearing stuck embedded runs.
So I’m closing this as already implemented rather than keeping a duplicate issue open.
Review details
Best possible solution:
Keep the terminal-state writer and next-turn recovery path, while handling explicit-model fallback policy in #84865 and token accounting in #66263.
Do we have a high-confidence way to reproduce the issue?
No — current main records a force-cleared run as terminal and re-admits a later visible turn; focused source coverage exercises that recovery boundary.
Is this the best way to solve the issue?
Yes — persisting terminal state at forced-clear ownership and recovering it at visible-turn admission fixes the producer-side invariant without fabricating token data or overriding an explicit model choice.
Security review:
Security review: This is issue triage without a proposed patch.
AGENTS.md: found and applied where relevant.
What I checked:
src/agents/embedded-agent-runner/runs.ts:938, 637de7d37945)src/config/sessions/terminal-status.ts:3, 637de7d37945)src/agents/embedded-agent-runner/runs.force-clear-terminal.test.ts:47, 637de7d37945)src/agents/agent-scope.ts:547, 637de7d37945)Likely related people:
src/agents/embedded-agent-runner/runs.ts,src/auto-reply/reply/dispatch-from-config.lifecycle.ts)src/agents/embedded-agent-runner/runs.ts)Codex review notes: model internal, reasoning high; reviewed against 637de7d37945; fix evidence: merged PR #112166, commit 87b76d0cd050, main fix timestamp 2026-07-27T10:55:57Z.
obviyus commentedon Jul 27, 2026
Reopening: #112166 fixes only force-clear terminal-state persistence. The broader provider fallback, token-display, session-recreation, and current-main reproduction questions remain unresolved.