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

Resolved 💬 5 comments Opened Apr 23, 2026 by SaturnityGL 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 ↗

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