Cannot resume session when context exceeds limit - no way to compact before loading

Resolved 💬 8 comments Opened Dec 18, 2025 by pnvoroshilov Closed Mar 27, 2026

Description

When a session's context grows large and is stopped, resuming it becomes impossible if the total context exceeds the model's limit. The error "Prompt is too long" occurs immediately upon resume, before any user interaction.

Problem

  1. Session runs normally, context grows over time
  2. Session is stopped (user closes terminal, or programmatic stop via SDK)
  3. User tries to resume session with --resume <session-id>
  4. Immediate error: "Prompt is too long"
  5. Cannot run /compact because the session must be loaded first to execute commands
  6. Deadlock: Session is too large to load, but must be loaded to compact

Steps to Reproduce

  1. Create a long-running session with many tool calls and large responses
  2. Stop the session before auto-compaction triggers
  3. Try to resume: claude --resume <session-id>
  4. Observe "Prompt is too long" error

Evidence

Session file size: 5.4 MB (201 lines in .jsonl)

$ ls -lah ~/.claude/projects/.../f2270107-6417-4c38-8808-e52dc63c42f4.jsonl
-rw------- 1 user staff 5.4M Dec 18 16:37 f2270107-...jsonl

Error in session history:

{
  "type": "assistant",
  "message": {
    "content": [{"type": "text", "text": "Prompt is too long"}]
  },
  "error": "invalid_request",
  "isApiErrorMessage": true
}

Expected Behavior

One of the following:

  1. Auto-compact on resume - If session exceeds limit, automatically compact before loading
  2. Offline compact command - Allow claude compact --session <id> without loading the full session
  3. Graceful degradation - Load only recent messages + summary when limit exceeded

Environment

  • Claude Code version: 2.0.72
  • OS: macOS
  • Using: Claude Code SDK (Python) with resume parameter

Workaround Attempted

  • Tried claude --resume <id> -p "/compact" - fails with same error because session must load first

Impact

Sessions that grow large become permanently inaccessible. Users lose all conversation history and must start fresh, losing context accumulated over potentially $7+ of API usage.

View original on GitHub ↗

This issue has 8 comments on GitHub. Read the full discussion on GitHub ↗