[BUG] 'Prompt is too long' error on ~50 word prompts in new sessions despite 80K+ free context
What's wrong
Brand new chat sessions reject prompts of approximately 50+ words with "Prompt is too long" error, despite having ~80K tokens of free context available (verified via /context command).
Environment:
- Claude Code version: 2.0.75
- VS Code extension version: 2.0.75
- OS: macOS Sequoia 15.x
- Model: Claude Opus 4.5 (claude-opus-4-5-20251101)
Context breakdown from /context command:
| Category | Tokens | Percentage |
|---|---|---|
| System prompt | 4.0k | 2.0% |
| System tools | 15.2k | 7.6% |
| MCP tools | 45.0k | 22.5% |
| Memory files | 7.9k | 4.0% |
| Messages | 1.7k | 0.9% |
| Free space | 81.0k | 40.5% |
What should happen
Prompts should be accepted when well within context limits. A ~50 word prompt (~75 tokens) should not be rejected when 81,000 tokens are available.
Steps to reproduce
- Open new Claude Code session in VS Code (with MCP servers configured)
- Run
/contextto verify available tokens (shows ~81K free / 200K total) - Send a message longer than approximately 50 words
- Receive "Prompt is too long" error
- Note: Shorter prompts sometimes work, longer ones consistently fail
Additional context
- Error occurs on brand new sessions with no conversation history
- Appears to be validation happening before API call (similar to #12312)
- This is a new issue that started recently
- Makes Claude Code unusable for normal development work - cannot send detailed prompts or paste code snippets
Found 2 possible duplicate issues:
- https://github.com/anthropics/claude-code/issues/12312
- https://github.com/anthropics/claude-code/issues/10745
This issue will be automatically closed as a duplicate in 3 days.
- If your issue is a duplicate, please close it and 👍 the existing issue instead
- To prevent auto-closure, add a comment or 👎 this comment
🤖 Generated with Claude Code
This is actually a critical issue. I cannot function at all now on any project. They're all corrupting like this.
Update: Additional debugging findings
I've narrowed down what triggers the "prompt is too long" error:
- First prompt in a new session with 2
@file references (e.g.,@CLAUDE.mdand@README.md) works fine - Second prompt adding 3 more
@file references triggers "prompt is too long" even though the actual text is just a sentence or two
This suggests the issue may be with how multiple file references are calculating/accumulating token counts, rather than the actual prompt length.
The validation seems to be miscounting or incorrectly accumulating tokens when multiple @ file references are used across messages.
Further update: Audio files may be the cause
Correction to my previous comment - the issue may be specifically with @ referencing audio files (binary), not the number of references.
I've used multiple @ file references many times before without issues, but this is the first time I've tried to reference audio files. Claude Code likely doesn't handle binary files properly when calculating token counts, or isn't meant to support them at all.
The @ references that triggered the error were .aiff or similar audio files.
Confirmed: Audio file @ references are the cause
Removing the @ symbols from the audio file references fixed the issue completely. The prompt works fine now.
Root cause: @ referencing binary/audio files triggers the "prompt is too long" error.
Suggested fix: Either:
- Show a clearer error like "Cannot reference binary files" instead of "prompt is too long"
- Or gracefully skip/ignore binary files with a warning
The misleading error message sent me down the wrong debugging path for a while.
Yeah this felt new to me today; I'm on uhh 2.0.67 right now. We were writing to a plan file and hit context limits. So I rewound a few messages and prompted that I edited the plan and to re-review with 4 short bullets. Still failed. I mean it's over 2mb in jsonl and I sent over 125 messages, but still not a good place to land users.
"sessionId": "43cb94d7-799c-487b-8696-0b4739557c14"
"text": "Prompt is too long"
"error": "invalid_request"
"content": "<command-name>/compact</command-name> ...
"content": "<local-command-stderr>Error: Error during compaction: Error: Conversation too long. Press esc twice to go up a few messages and try again.</local-command-stderr>"
Hit it again..But this time I decided to try claude -c -f to fork it instead. Compact worked.