[BUG] "Prompt too long" with respect to ridiculous session token usage.

Status Fixed / completed
Maintainer reply None cached
Activity 5 comments · opened Apr 23, 2026 · closed Apr 23, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

During an active multi-step agentic session, Claude Code throws a "Prompt too long" error well before the context window is actually full, in my case at approximately 85% context usage. Once this error appears, the session is completely unrecoverable; no further prompts are accepted and I have to abandon the session entirely. This requires starting a new session, and updating the new Claude Code version with whatever the interrupted Claude Code was working on, producing a HUGE waste of time and tokens and basically ruining a session limit, I've never had 5-hour session limits kick in within 20 minutes with a single prompt and some small refining.

This is extremely destructive mid-rebuild. In this specific instance, Claude Code had completed a major write pass, I issued a follow-up to rebuild a portion of the output, and the error surfaced partway through that rebuild. The session was irrecoverable despite significant remaining context headroom. Once the "Prompt too long" error kicks in, it doesn't matter what you do, as the error persists, you aren't able to even manually initiate a compaction.

It strongly appears that auto-compaction is not triggering when it should. Context is allowed to accumulate until an API-level rejection, rather than compaction firing proactively and freeing space. Previously I could complete multiple major tasks in a single session with no issues, this regression appears to be recent. I could in-fact do MULTIPLE large prompts in a single session without issue, but now it appears that something is greatly inflating values, quicker than the application possibly expects, not kicking the auto-compaction on and bricking the entire session.

What Should Happen?

Auto-compaction should fire before the prompt reaches the hard limit, freeing enough context to continue the session. If compaction cannot reduce context sufficiently, the user should receive a clear warning not a hard crash at ~70% that prevents all further interaction. The session should remain usable or at minimum allow a clean /clear or /compact recovery path. _And not inflate the token count massively_.

Error Messages/Logs

Prompt too long

(Error appears inline in the Claude Code UI mid-response, with no further output. Session becomes unresponsive to new prompts.)

Steps to Reproduce

  1. Start a Claude Code session in a project with a non-trivial CLAUDE.md and several source files.
  2. Issue a somewhat simple multi-step task (e.g. write a large module or document)
  3. Allow Claude to complete the task, observe context climbing to ~80%
  4. Issue a follow-up task asking Claude to re-evaluate, revise, or rebuild a portion of the output
  5. Observe "Prompt too long" error mid-execution, despite context window not being full
  6. Attempt any further prompts observe that the session is frozen/unresponsive.

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

Prompt is too long.

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Windows Terminal

Additional Information

I'll edit it later, as I can't ADD my Claude Code version, as even using claude --version gives an error, and as a plus, the recent break I had entirely erased my whole session usage, so no way to check the version, and even turning on extra usage still doesn't allow Claude Code to continue. Everything has been perfectly fine except for today and yesterday.

<img width="653" height="290" alt="Image" src="https://github.com/user-attachments/assets/7e3e7a25-1e02-4b49-b323-19466b12ea29" />

View original on GitHub ↗

5 Comments

github-actions[bot] · 5 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/45117
  2. https://github.com/anthropics/claude-code/issues/42084
  3. https://github.com/anthropics/claude-code/issues/30400

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

SaturnityGL · 5 months ago
Found 3 possible duplicate issues: 1. /compact and auto-compaction both broken — fails across sessions/models/subscriptions; auto-compact sometimes fires at 30% context; /feedback also fails #45117 2. [[BUG] Context limit lockout — @mention agent also fails, session completely unrecoverable #42084](https://github.com/anthropics/claude-code/issues/42084) 3. [[Bug] Context limit reached without automatic compaction triggering #30400](https://github.com/anthropics/claude-code/issues/30400) 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

Close, but no, as those are talking about a context window limit being reached. Mine isn't even being reached

SaturnityGL · 5 months ago

Okay, I turned off automatically closing it, so uh.. Nice. The issue is not supposed to close.

junaidtitan · 5 months ago

Hit this exact wall — session bloat accumulates until the API rejects it and auto-compact can't fire in time. Cozempic's guard daemon pre-prunes the JSONL continuously at 4 thresholds so you never reach the 'prompt too long' state. 18 strategies strip stale tool results, old file reads, and accumulated bloat before it snowballs.

pipx install cozempic && cozempic guard — https://github.com/Ruya-AI/cozempic

github-actions[bot] · 5 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.