Skip to content

[Bug]: claude-cli fallback turn loses prior session context even though Claude session file still has full history #69973

@aounakram

Description

@aounakram

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

When using claude-cli/claude-sonnet-4-6, a turn that falls back away from Claude can lose all prior context for the fallback model, even though the original Claude local session file still contains the fuller history and later Claude turns continue writing to that same file.

This makes the fallback turn behave as if the conversation just started with the first post-fallback message.

Steps to reproduce

  • Long-running claude-cli session with Sonnet
  • Claude appears to do server-side compaction/summarization silently at times
  • Sometimes important context is lost after compaction
  • In the specific failure case below, Claude hit a usage/billing limit and OpenClaw fell back for that turn
  • The fallback model appeared to have no prior context at all
  • However:
    • the Claude local session file under ~/.claude/projects/*/*.jsonl still had the fuller history
    • later turns continued writing to that same Claude session file
    • /status still showed claude-cli/sonnet*

Relevant log

02:05:07+00:00 info agent/cli-backend {"subsystem":"agent/cli-backend"} cli exec: provider=claude-cli model=sonnet promptChars=1034
02:05:09+00:00 warn model-fallback/decision {"subsystem":"model-fallback/decision"} {"event":"model_fallback_decision","tags":["error_handling","model_fallback","candidate_failed"],"runId":"fc48945f-bf07-481d-bf19-c472d07c859c","decision":"candidate_failed","requestedProvider":"claude-cli","requestedModel":"claude-sonnet-4-6","candidateProvider":"claude-cli","candidateModel":"claude-sonnet-4-6","attempt":1,"total":10,"reason":"billing","status":402,"errorPreview":"You're out of extra usage · resets 11pm (America/New_York)","errorHash":"sha256:9f33328f03be","nextCandidateProvider":"openai-codex","nextCandidateModel":"gpt-5.4","isPrimary":true,"requestedModelMatched":true,"fallbackConfigured":true} model fallback decision

Session file observations

  • ~/.claude/projects/*/*.jsonl contains the fuller current Claude session history
  • ~/.openclaw/agents/*/sessions/ only shows the newer truncated current session plus older sessions
  • The fallback model behaved as if only the first post-fallback message existed

Expected behavior

When using claude-cli/claude-sonnet-4-6, a turn that falls back away from Claude can lose all prior context for the fallback model, even though the original Claude local session file still contains the fuller history and later Claude turns continue writing to that same file.

This makes the fallback turn behave as if the conversation just started with the first post-fallback message.

Actual behavior

The fallback turn appears to have no prior context, even though the fuller Claude-side session history still exists locally and the overall session later continues on Claude.

OpenClaw version

OpenClaw 2026.4.15 (041266a)

Operating system

macOS 26.3.1

Install method

npm global

Model

claude-cli/claude-sonnet-4-6

Provider / routing chain

openclaw -> claude-cli

Additional provider/model setup details

No response

Logs, screenshots, and evidence

02:05:07+00:00 info agent/cli-backend {"subsystem":"agent/cli-backend"} cli exec: provider=claude-cli model=sonnet promptChars=1034
02:05:09+00:00 warn model-fallback/decision {"subsystem":"model-fallback/decision"} {"event":"model_fallback_decision","tags":["error_handling","model_fallback","candidate_failed"],"runId":"fc48945f-bf07-481d-bf19-c472d07c859c","decision":"candidate_failed","requestedProvider":"claude-cli","requestedModel":"claude-sonnet-4-6","candidateProvider":"claude-cli","candidateModel":"claude-sonnet-4-6","attempt":1,"total":10,"reason":"billing","status":402,"errorPreview":"You're out of extra usage · resets 11pm (America/New_York)","errorHash":"sha256:9f33328f03be","nextCandidateProvider":"openai-codex","nextCandidateModel":"gpt-5.4","isPrimary":true,"requestedModelMatched":true,"fallbackConfigured":true} model fallback decision

### Session file observations
- `~/.claude/projects/*/*.jsonl` contains the fuller current Claude session history
- `~/.openclaw/agents/*/sessions/` only shows the newer truncated current session plus older sessions
- The fallback model behaved as if only the first post-fallback message existed

Impact and severity

No response

Additional information

This looks like a turn-level fallback continuity issue rather than the original Claude session being fully lost.

Additional observation

After the Claude usage window reset, subsequent turns again ran normally on claude-cli/sonnet with no fallback/session reset in logs. This suggests the original Claude session itself remained alive, and the context loss was specific to the fallback turn/handoff rather than the Claude session being destroyed.

Confirmed follow-up

After the Claude usage window reset, I asked the same Claude session for a summary and it returned the full expected context. This confirms the original Claude session/history was still intact. The context loss appears specific to the fallback turn/handoff, not to the Claude session being destroyed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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