Skip to content

Session context lost on Claude CLI rotation — conversation amnesia between messages #80905

@jarvis-drakon

Description

@jarvis-drakon

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions