anthropics / anthropics/claude-code

[BUG] False "Context limit reached" when well within limit

オープン
#91,709 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
area:core bug platform:windows
主要言語
Python
スター
145k
フォーク
23.1k
PR マージ指標
PR 指標を取得中

説明

### Preflight Checklist

- [x] I have searched [existing issues](https://github.com/anthropics/claude-code/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug) 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?

**NOTE: I looked at every "potential duplicate" and see no overlap with this issue.**

After freshly restarted, and first session post-update, first message failed with "context limit reached /compact or /clear [etc]"

This is a false flag. According to /context I still have about 100k left in the project window and a simple first greeting (no tools, no requests) should not have pushed beyond any such amount, including the compact buffer. I can't imagine any simple message costing 100k in context because I would reach the 1M limit in like 10 messages.

**POSSIBLE CAUSES:**
- Possible wires crossed with USAGE limit? Usage limit is indeed at 96% for the 5-hour window, but only at around 10% for the week. I don't understand HOW these flags could get crossed, but it's the only thing I can see that even makes sense for the situation.
- Too many updates stacked before finally restarting terminal? Conflicts caused?
- **SEVERE Misread on prompt cost. Clue: when checking my RC to see what's populated on that side, the response to my simple greeting is "Prompt is too long."** (WHY WOULD A FORMALITY LIKE "I'm back" COST 100K IN CONTEXT)

### What Should Happen?

Claude should *not* flag context limit reached when context limit is *not* indeed reached.

If a simple greeting somehow is pushing context beyond 100k tokens, perhaps the message cost should actually be appended to the flag such as "context limit reached - current message cost = _____" (so that we can further conclude the math isn't mathing.)

### Error Messages/Logs

```shell
⎿  Context limit reached · /compact or /clear to continue · auto-compact is off · /config to turn it on
```

### Steps to Reproduce

I reached here by:

1. Reaching a comfortable pause point in a large project and finally feeling OK to restart with pending updates. To note, I DO NOT prefer to update mid-project because of previous issues that have occurred (much like this). I will try to finish as much as I can and back everything up before doing so. The project is still not finished and I am now locked out unless I compact.

2. Used ctrl+c twice to exit cleanly before closing terminal. Restarted terminal.

3. Re-launched Claude Code with --resume. Zero messages sent. No usage. Was notified in bottom-right flag that Updates still need one more restart.

4. Used ctrl+c twice to exit cleanly before closing terminal. Restarted terminal.

5. Re-launched Claude Code with --resume. Sent simple greeting.

6. Greeted back with context limit reached.

7. Checked /usage and /context. No such limit should be claimed.

### Claude Model

Opus

### Is this a regression?

I don't know

### Last Working Version

_No response_

### Claude Code Version

2.1.259

### Platform

Anthropic API

### Operating System

Windows

### Terminal/Shell

PowerShell

### Additional Information

**Usage Setup:**
Claude Code CLI on desktop.
Opus 4.7 only. Medium Effort by default.
RC running but not used.
Minimal connectors/tools active.
Previous version BEFORE update - likely 2.1.241
Previous working state: context available to be filled up to nearly 995k. Hit this state multiple times.

**Additional Explainers:**
Usually in my projects around 800k context, I will do a pre-compact preparation pass. This pass includes logging, archiving, backing things up for the potential chaos that compacting or updating is about to cause. The "comfortable pause point" mentioned occurred later than normal at around 890k context simply due to the nature of not being able to find a break in the project that made sense. This break WAS intended to be the window for my pre-compact pass. Being locked out of the model and usage **_right now_** is too funny.

Why did I hold off on the pre-compact pass til after updating instead of doing it before? Because I had caught _another_ bug bloating my usage and realized I should update before it bloats it any further. The way I caught that bug was because I have a sort of muscle memory for the type of work I do and how much it costs and realized my usage was bloating FAR beyond what it should. Thus some time prior to updating, I experimented and waited til cache dumped, and until a brand new 5-hour session started. I sent a simple test prompt. Saw the 5-hour usage jump 35%. Sent a second test prompt seconds later (within warm cache). Saw the 5-hour usage jump to 70%. ABSOLUTELY RIDICULOUS.

This is not an additional bug I am reporting, just supplying for the narrative. When looking at changelogs I saw that this may have been addressed. Hence I updated before thinking to do my preparatory pass. Learned my lesson. Don't trust any update. Always back up and log beforehand. I still intend to do what I can manually. But this is such a slap in the face.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Start by reproducing the report on Windows PowerShell with Claude Code 2.1.259: launch with --resume, send a simple greeting, then compare /context and /usage with the context-limit message. Check the behavior of /compact, /clear, and /config as related entry points. Done means a greeting within the reported available context is accepted and the displayed context and usage state agree.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
powershell, python
領域
api, cli
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
活発
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。