openclaw - 💡(How to fix) Fix Session context lost on Claude CLI rotation — conversation amnesia between messages [3 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

When the Claude CLI session underlying a conversation rotates (due to gateway restart, context compaction, or session timeout), the new Claude CLI process has no knowledge of the prior conversation. From the user's perspective, the AI has gone blank mid-conversation.

Root Cause

OpenClaw continues sessions using --continue <session-id>. When the process for that session has exited, a new CLI session is started. The new session begins with only the system prompt and no conversation history.

The contextPruning settings (ttl, keepLastAssistants) do not address this — they govern in-session pruning, not cross-session continuity.

Fix Action

Fixed

RAW_BUFFERClick to expand / collapse

Summary

When the Claude CLI session underlying a conversation rotates (due to gateway restart, context compaction, or session timeout), the new Claude CLI process has no knowledge of the prior conversation. From the user's perspective, the AI has gone blank mid-conversation.

Behaviour

  1. User sends a message → Claude CLI session A handles it and responds
  2. For any reason, session A ends (gateway restarts, compaction fires, timeout, etc.)
  3. User sends a follow-up message → Claude CLI session B is spawned fresh
  4. Session B has no awareness of anything discussed in session A

The session transcript IS persisted to disk (.openclaw/agents/main/sessions/<session-id>.jsonl and ~/.claude/projects/.../<session-id>.jsonl), but it is not replayed into the new session on resume.

Root Cause

OpenClaw continues sessions using --continue <session-id>. When the process for that session has exited, a new CLI session is started. The new session begins with only the system prompt and no conversation history.

The contextPruning settings (ttl, keepLastAssistants) do not address this — they govern in-session pruning, not cross-session continuity.

Proposed Fix

On session resume (when the Claude CLI process for a session key no longer exists), OpenClaw should replay the recent transcript from disk into the new session before routing the user's message. A configurable resumeHistoryMessages limit (e.g. last N messages or last X tokens) would allow this without blowing up context on long conversations.

Observed Impact

  • User messages are answered without context of prior exchange
  • AI asks for clarification on things already established
  • Trust and usability degraded, especially for multi-turn workflows

Environment

  • OpenClaw version: 2026.5.2
  • Session mode: dmScope: per-peer
  • Context pruning: cache-ttl, ttl 24h, keepLastAssistants 20
  • Claude CLI model: claude-sonnet-4-6 via OAuth

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Session context lost on Claude CLI rotation — conversation amnesia between messages [3 pull requests]