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
- Session runs normally, context grows over time
- Session is stopped (user closes terminal, or programmatic stop via SDK)
- User tries to resume session with
--resume <session-id>
- Immediate error: "Prompt is too long"
- Cannot run
/compact because the session must be loaded first to execute commands
- Deadlock: Session is too large to load, but must be loaded to compact
Steps to Reproduce
- Create a long-running session with many tool calls and large responses
- Stop the session before auto-compaction triggers
- Try to resume:
claude --resume <session-id>
- 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:
- Auto-compact on resume - If session exceeds limit, automatically compact before loading
- Offline compact command - Allow
claude compact --session <id> without loading the full session
- 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.
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
--resume <session-id>/compactbecause the session must be loaded first to execute commandsSteps to Reproduce
claude --resume <session-id>Evidence
Session file size: 5.4 MB (201 lines in .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:
claude compact --session <id>without loading the full sessionEnvironment
resumeparameterWorkaround Attempted
claude --resume <id> -p "/compact"- fails with same error because session must load firstImpact
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.