claude-code - 💡(How to fix) Fix [BUG] "Prompt too long" with respect to ridiculous session token usage. [3 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52583Fetched 2026-04-24 06:03:16
View on GitHub
Comments
3
Participants
2
Timeline
9
Reactions
0
Timeline (top)
labeled ×4commented ×3closed ×1cross-referenced ×1

Error Message

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.

Error Messages/Logs

(Error appears inline in the Claude Code UI mid-response, with no further output. Session becomes unresponsive to new prompts.) 5. Observe "Prompt too long" error mid-execution, despite context window not being full 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.

Code Example

Prompt too long

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

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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" />

extent analysis

TL;DR

The most likely fix is to wait for an update that addresses the auto-compaction issue or to manually manage session context to prevent the "Prompt too long" error.

Guidance

  • Verify that the issue is indeed related to auto-compaction not triggering by monitoring context usage and checking if manual compaction helps.
  • Try breaking down large tasks into smaller ones to reduce context accumulation and prevent the error.
  • If possible, check the Claude Code version to see if this is a known issue in the current version.
  • Consider reaching out to the developers or support team for further assistance or to report the issue.

Example

No code snippet is provided as the issue seems to be related to the Claude Code application itself rather than user code.

Notes

The exact cause of the issue is unclear, but it appears to be related to a regression in the auto-compaction feature. Without more information about the version or specific usage patterns, it's difficult to provide a more targeted solution.

Recommendation

Apply workaround: Break down large tasks into smaller ones to reduce context accumulation and prevent the error, as the issue seems to be related to a regression in the auto-compaction feature and waiting for an update might take time.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] "Prompt too long" with respect to ridiculous session token usage. [3 comments, 2 participants]