[BUG] API Error: Claude's response exceeded the 32000 output token maximum.

Open 💬 139 comments Opened Feb 8, 2026 by patrikhuber
💡 Likely answer: A maintainer (ashwin-ant, collaborator) responded on this thread — see the highlighted reply below.

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?

Hi,

I just asked Claude Code to implement something relatively hard. After 8 minutes of thinking, there is this error in the Claude Code terminal window:

⎿  API Error: Claude's response exceeded the 32000 output token maximum. To configure this behavior, set the

CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.

However it still seems to be thinking (14 minutes now), so it's probably still going. It hasn't given me any feedback of what it's doing or thinking.

✽ Shenaniganing… (11m 35s · ↓ 35.0k tokens · thinking)

Claude Code on PowerShell on Windows Terminal, Windows 11, latest version (updated today). Using Opus 4.6. On the Pro plan currently.

I found a few related issues (other users encountering this issue) but they are all closed or in a different context.

What Should Happen?

No error, or a better explanation.

Error Messages/Logs

API Error: Claude's response exceeded the 32000 output token maximum. To configure this behavior, set the
     CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.

Steps to Reproduce

I can share my prompt privately if you want to contact me. But I suspect this is reproducible with any prompt that requires long thinking (very complex task).

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.37 (Claude Code)

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Windows Terminal

Additional Information

_No response_

View original on GitHub ↗

139 Comments

carrotRakko · 5 months ago

Same error here on Opus 4.6 (v2.1.37). I also tried setting CLAUDE_CODE_MAX_OUTPUT_TOKENS=64000 but the 32000 limit remained unchanged. Filed a separate report for that: #24159

✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)

patrikhuber · 5 months ago

I also find the documentation (https://code.claude.com/docs/en/settings) confusing:

> CLAUDE_CODE_MAX_OUTPUT_TOKENS | Set the maximum number of output tokens for most requests. Default: 32,000. Maximum: 64,000. Increasing this value reduces the effective context window available before auto-compaction triggers.

First, this docs page (https://platform.claude.com/docs/en/about-claude/models/overview#model-comparison-table) says Opus 4.6's output limit is actually 128K, so above the max of 64k that the other docs page lists (perhaps this just hasn't been updated for the Opus 4.6 release).

Second, I'm generally confused as a user what to do. It sounds like to make this error go away, I have to set CLAUDE_CODE_MAX_OUTPUT_TOKENS to 128K. But then increasing this value reduces my context window - so I probably don't want to do that? (I also don't understand why increasing the max output would reduce my context window?).

Would be nice to make this clearer/easier for the user.

nullbio · 5 months ago

This is driving me insane. I'm using Codex in the mean time. CC literally unusable right now. It takes 15 minutes to do a single task at the best of times, and we have no visibility into what is happening. I used a packet inspection tool to see if I could figure out where it's getting stuck, and quite often it's just sitting on an open TCP connection waiting for SSE events to come back from Anthropic. In other words, we're just waiting in a queue, forever.

In a more related case, it was sitting there for 12 minutes and 30 seconds to redesign a landing page, all it did was adjust some wording and colors. There's major problems and no one seems to be speaking about it. Genuinely thinking about cancelling my max sub at this point because I can't use CC like this and Anthropic seems to just ignore everyone so I doubt it'll get fixed any time soon.

● Direction confirmed.

  Let me build it.
  ⎿  API Error: Claude's response exceeded the 32000 output token maximum. To configure this behavior, set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.

● Writing the redesigned page now.

12 minutes to get to that API error after "Direction confirmed".

stefansimik · 5 months ago
I also find the documentation (https://code.claude.com/docs/en/settings) confusing: > > CLAUDE_CODE_MAX_OUTPUT_TOKENS | Set the maximum number of output tokens for most requests. Default: 32,000. Maximum: 64,000. Increasing this value reduces the effective context window available before auto-compaction triggers. First, this docs page (https://platform.claude.com/docs/en/about-claude/models/overview#model-comparison-table) says Opus 4.6's output limit is actually 128K, so above the max of 64k that the other docs page lists (perhaps this just hasn't been updated for the Opus 4.6 release). Second, I'm generally confused as a user what to do. It sounds like to make this error go away, I have to set CLAUDE_CODE_MAX_OUTPUT_TOKENS to 128K. But then increasing this value reduces my context window - so I probably don't want to do that? (I also don't understand why increasing the max output would reduce my context window?). Would be nice to make this clearer/easier for the user.

I have exactly the same question

alalalalalalalaal · 5 months ago

Same issue, even changing the variable value seems to do nothing

stefansimik · 5 months ago

Is it possible, that the variable CLAUDE_CODE_MAX_OUTPUT_TOKENS is applied when used API, but not when using subscription?

old8man · 5 months ago

Yeah, it's a major issue. First we had a 128K limit (Max plan), then it shrank to 64K, and now we're slumming it at a measly 32K. I’d get it if claude code or Opus were actually designed to write to new files in bite-sized chunks. But right now, the model is just mindlessly incinerating tokens, utterly failing to save a single large file of its own creation. And to top it off, it repeats this little circus act two or three times, cheerfully flushing my paid subscription tokens down the drain. It’s absolute, unadulterated nonsense. Anthropic, have a heart )

srb3 · 5 months ago

Same issue for me, I tried changing the env var value but it did not seem to fix the issue

old8man · 5 months ago

<img width="1170" height="267" alt="Image" src="https://github.com/user-attachments/assets/be4081e8-9f3c-431a-8a20-127497d022f6" />

Tokens are just going up in smoke for nothing - please fix this embarrassment.

jzuiddam · 5 months ago

This urgently needs a fix. This is an issue on all platforms, latest version, occurring in lots of scenarios. At least the error message should be changed to make sense.

stefansimik · 5 months ago

Exactly, these very small output limits are completely unusable. I am forced to use Gemini 3 Pro instead as quick saviour.
Many of my flows using latest Opus 4.6 are full of API errors now. Setting max output tokens does not work at all.
Please fix this urgently 🙏

Tacticalninja19 · 5 months ago

Having the same issue. Asking it to do a small task and it thinks and second guesses itself until the 32000 output token max is reached and then it starts all over again.

mafonta · 5 months ago

I am on the Max 20x plan and I am also experiencing these issues. In the new /fast mode it did eventually complete the task - but burned ~$8 in ~5 minutes. At 4% of my monthly plan cost, it seems like an extreme premium just to be able to complete what was up until recently an "every day" task.

whoan · 4 months ago

Same here, using Sonnet 4.5

  ⎿  API Error: Claude's response exceeded the 32000 output token maximum. To configure this behavior, set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.
  ⎿  API Error: Claude's response exceeded the 32000 output token maximum. To configure this behavior, set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.

✻ Beaming… (19m 13s · ↓ 99.6k tokens · thinking)

Feels like tokens (and usd) are just getting into a black hole.

ak-1 · 4 months ago

Without guidance Opus 4.6 tries to generate huge files in one go. I solved this by explaining the situation and advise it to split the plan items / work packages into smaller pieces and to implement, test and commit each one individually.

harshvasudeva · 4 months ago

This just feels like scam. All the usage got wasted coz of this.

serefarikan · 4 months ago

Just hit this while CC tried to build a serialiser from some domain types to mermaid. @nullbio 's observation about the time it takes for stuff that CC usually completed in a few minutes is also accurate. it is minute 20+ at the moment to generate at most a couple of hundred lines of code.

oOblik · 4 months ago

Also seeing this for relatively simple tasks and Sonnet 4.6.

kobi2187 · 4 months ago

you should retract the usage tokens, if claude couldn't complete the response.

swabfu · 4 months ago

+1 I'm on the pro plan and this just blew through 30% of my 5h limit only to fail with the 32k limit. Retrying in a new session now (I had compacted the previous session then tried to run a big investigation to generate a plan for a bugfix) so it may be related to compacting, dunno. should really get those tokens back because it worked for 13 minutes only to fail and give me absolutely nothing, now I'm having to redo the prompt and waste even more tokens especially as it's a context-fresh session. the issue needs attention!

gkobeaga · 4 months ago

19 minutes on "Bake" and got charcoal, please verify your smoke detectors.

Claude Code: v2.1.45
Platform: Linux

<img width="1629" height="323" alt="Image" src="https://github.com/user-attachments/assets/8c0f19f1-8f99-4505-b441-b5ae85315fd4" />

gknops · 4 months ago

Just got bitten by this too. Chomped through the session limit and never generated useful output. That should trigger a refund.

nullbio · 4 months ago
API Error: Claude's response exceeded the 64000 output token maximum. To configure this
       behavior, set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.

Love this. Now it's 64,000, not 32,000.

Then I restarted the app, and all of a sudden working way faster (and by way faster I mean... Still painfully slow but way faster than molasses).

There's obviously a bug causing degradation of network connections or background processes silently.

LongjieGuo · 4 months ago

Running into the same issue here. Had CC follow a todo list of something relatively complicated and it got stuck in the first step.

Chandrakanth10 · 4 months ago

⎿  API Error: Claude's response exceeded the 32000 output token maximum. To configure this behavior, set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.

getting the same error as well

SPetersonNICE · 4 months ago

Same error. It churned for 8 minutes and stopped with no feedback and no file-writes. Only when I asked it "what went wrong? Please explain, and complete the task" did it print the error, (before thinking 8 more minutes and finally writing the files).

1) Should print clear and timely error message
2) Should write updates to one file at a time, not try to buffer an unlimited response before writing.
3) Should write what it has to disk (somewhere, anywhere) when the error occurs. Not hold it in memory or discard it.

Bonus Feedback:
Why is ClaudeCode hitting a "response limit" and not just breaking the response into pieces?...
In the last six months, I never got this type of error in VSCode Copilot with Claude Sonnet 4.5 working on production code. However in the first week of testing ClaudeCode in a small sandbox project, here we are.

nullbio · 4 months ago
✻ Churning… (19m 46s · ↓ 57.1k tokens · thought for 3s)

● Searched for 1 pattern, read 13 files (ctrl+o to expand)
  ⎿  API Error: Claude's response exceeded the 64000 output token maximum. To configure this behavior, set the
     CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.
mufeiyu-ayu · 4 months ago

Why hasn't this problem been solved yet? Can't you have a bit of conscience? How many tokens have I wasted, damn it.

suglasp · 4 months ago

same problem : Yesterday asked it _one question_ in Claude Code Planning mode how it would change an existing script file.
It was reasoning, spawned the error a few times. I've stopped it.
Asked the same question. Did a long time reasoning, no action being taken. Ran out of tokens with again the error a few times, and my session tokens used up.
Today tried again for the same script. It updated the claude.md planning file. Then I asked it to change the code according to it's plan. Same error and burned 75% of my token limit.

Chandrakanth10 · 4 months ago

Hi I was able to solve this temporarly by asking specific questions, instead of asking to do a lot in one step I started to ask the model to do small tasks and it was able to do those tasks. I would suggest you to try that.

fuomag9 · 4 months ago

Same, exhausted my tokens for NOTHING.

paulocoutinhox · 4 months ago

Same here, waiting a long time for nothing. Maybe it is proposital to make us cast more tokens?

nullbio · 4 months ago

It would be nice if we at least had acknowledgements from Anthropic when they're working on certain things, or we at least know they've seen it. I'll be honest and say that the radio silence on issues makes it feel like they don't care about their customers.

paulocoutinhox · 4 months ago

API Error: Claude's response exceeded the 64000 output token maximum. To configure this behavior, set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.

Im making in other models like Kimi code, because is impossible with opus/anthropic.

cpj-dev · 4 months ago

Same issue, run out of my tokens to get these hilarious errors.

paulocoutinhox · 4 months ago

After a lot of bugs/error: You've hit your limit · resets 2am (America/Sao_Paulo). It cast all my plan only with bugs/errors.

Sivakumar-finoli · 4 months ago

Faced the same problem. Changed the AI model to Opus 4.6 or Haiku 4.5 to get it working. The problem seems to be with the latest Sonnet 4.6 model - which was the default. Hope this issue is fixed soon in Sonnet 4.6.

jzuiddam · 4 months ago
Faced the same problem. Changed the AI model to Opus 4.6 or Haiku 4.5 to get it working. The problem seems to be with the latest Sonnet 4.6 model - which was the default. Hope this issue is fixed soon in Sonnet 4.6.

I only run Opus 4.6 and have this issue all the time.

aspiziri · 4 months ago

+1 to this problem. Seems to have been an issue for me the past 2 days. I ask a question that normally would have resulted in a completed action in ~20 seconds but instead now runs for 10 minutes, spits out that error and then goes for another 5 before I finally give up and abort it.

fuomag9 · 4 months ago
+1 to this problem. Seems to have been an issue for me the past 2 days. I ask a question that normally would have resulted in a completed action in ~20 seconds but instead now runs for 10 minutes, spits out that error and then goes for another 5 before I finally give up and abort it.

Same behaviour, does it even with different prompts (i.e. has ZERO prompt adherence)

Sivakumar-finoli · 4 months ago
> Faced the same problem. Changed the AI model to Opus 4.6 or Haiku 4.5 to get it working. The problem seems to be with the latest Sonnet 4.6 model - which was the default. Hope this issue is fixed soon in Sonnet 4.6. I only run Opus 4.6 and have this issue all the time.

I'm using claude plugin with vscode. Did not face any problem with the default sonnet model till a couple of days back when 4.6 was released. I switched to opus 4.6 today - it worked but after a couple of prompts my token quota was over and not usable. Hope it works when I use it next

dans-stuff · 4 months ago

``API Error: Claude's response exceeded the 32000 output token maximum. ``

I have ended my max plan until these issues (huge delays in responses, and arbitrary burning of tokens) are resolved. The Anthropic restaurant wastes an hour burning your pie and charges you for an empty plate. The solution is clear: store any partial outputs in a temp file and instruct Claude Code to reference it, as you do for some errors already.

ipedrazas · 4 months ago

Same

Read 1 file (ctrl+o to expand)
  ⎿  API Error: Claude's response exceeded the 32000 output token maximum. To configure this behavior, set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.
  ⎿  API Error: Claude's response exceeded the 32000 output token maximum. To configure this behavior, set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.
Xefan · 4 months ago

+1 Claude seems to be completely broken now only a few days after I upgraded to Max. It just can't complete any work without running into this error yet burns tokens in the process.

Worse, this was working fine with a Claude session I had open until yesterday over the last week, it's only now I've restarted and started a new fresh session that it no longer works.

maelp · 4 months ago

Claude is super slow, broken, and makes mostly mistakes... has there been a wrong update of the models?

madadiuk · 4 months ago

I have the same issue, i recomond when you ask any requests, make it in a few different messages, It is working well. as much possible try to get one part of task in one message and get a summary then open another message and same, sometimes because of heavy loading we can get problem even i am in max memebership.

nw340driver · 4 months ago

Same issue. Following this thread. Unable to locate any settings.json file locally. No idea where to find such a file on cloud, but sounds like it wouldn't make a difference.

Like others, I feel like Claude is burning tokens with each attempt that ends in failure. This apperas seem to be a bug, not a configuration issue.

swlittles · 4 months ago

Good ol Anthropic. Do they actually have software engineers anymore or do they outsource their work to Haiku ? Leaning towards Haiku.

BILLIONS OF DOLLARS in the bank but can't go through a release without major issues.

serhii-chernenko · 4 months ago

same here in planning mode, waiting for 20 minutes

API Error: Claude's response exceeded the 32000 output token maximum. To configure this behavior, set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.

<img width="3484" height="2064" alt="Image" src="https://github.com/user-attachments/assets/9081ec8f-3579-44be-a228-5e1ca33821f9" />

suglasp · 4 months ago

Seems changing the thinking effort to low, OR switching back to the old models can fix the problem of the models to over reason.
~\\.claude\\settings.json
{
"model": "sonnet",
"thinkingEffort": "low"
}

or env vars to set to old models:
C:\ > set ANTH
ANTHROPIC_DEFAULT_OPUS_MODEL = "claude-opus-4-5-20251101"
ANTHROPIC_DEFAULT_SONNET_MODEL = "claude-sonnet-4-5-20250929"
ANTHROPIC_DEFAULT_HAIKU_MODEL = "claude-haiku-4-5-20251001"

meanbeanmachine · 4 months ago
changing the thinking effort to low

I don't pay $200 a month for Claude to operate at low effort. Unacceptable, Anthropic.

lsulliv · 4 months ago

This is awesome. Burned my entire session limit on this error and got nothing done.

krausality · 4 months ago

I have the same issue and i am dissatisfied with the handling of it.

infinitenewworld · 4 months ago

This fucking sucks, I just bought a yearly plan on the reccomendation of a friend, fired it up, and it's broken haha. haven't been able to do anything with it

taykent-debug · 4 months ago

Probably different issue with what is reported above but I faced this issue twice ( with glm-4.7 model ) when claude code (v2.1.50) enters into a loop where it continuously tries to do the same thing over and over, which was visible in detailed transcript (ctrl+o) for a short period of time, where detailed transcript for the looping output vanished after giving an interrupt.

nullbio · 4 months ago

I wonder when some tech influencers are going to start talking about this giant elephant in the room: Anthropics communication in regards to bugs/issues.

How do we know when they're working on something? How do we know that they've even seen this? Or should we keep screaming from the void?

This system is not working at all. No issue assignments to Anthropic team members, no comments from them on any issue on Github, no management of the GH issues list. They're alienating their user base and seemingly do not care.

fuomag9 · 4 months ago
Probably different issue with what is reported above but I faced this issue twice ( with glm-4.7 model ) when claude code (v2.1.50) enters into a loop where it continuously tries to do the same thing over and over, which was visible in detailed transcript (ctrl+o) for a short period of time, where detailed transcript for the looping output vanished after giving an interrupt.

I first had this issue while trying out my local model (which is supported by Claude as a feature) so I tought it was maybe me that had done something wrong, but even the variable setting doesn’t work :/

And then this also happened on my pro account (but not always? Today I managed to get Claude work again on 4.6 sonnet when working with a different task)

roblevintennis · 4 months ago

I'm hitting this too. Sounds like something @bcherny would want to be aware of (just listened on Lenny's podcast and he supposedly fixes bugs "in minutes"). This would sure be a nice one to tackle for the users.

serhii-chernenko · 4 months ago

Is this somehow related?
https://x.com/anthropicai/status/2025997928242811253?s=46

Maybe Anthropic decided to limit all users in case of preventing attacks

pcgeek86 · 4 months ago

Just updated to the latest version of the Claude Code CLI and ran into this myself.

  • PowerShell Core
  • VSCode Terminal
  • MacOS Tahoe 26.3
  • Claude Code CLI version
  • Used the Notion MCP server to retrieve documentation - this is where it failed
  • My Claude Code session is hung 13+ minutes
nullbio · 4 months ago
Just updated to the latest version of the Claude Code CLI and ran into this myself. PowerShell Core VSCode Terminal MacOS Tahoe 26.3 Claude Code CLI version Used the Notion MCP server to retrieve documentation - this is where it failed My Claude Code session is hung 13+ minutes

https://github.com/anthropics/claude-code/issues/26224

wrenna-robson · 4 months ago

Running into this myself - it's exceedingly frustrating because there's just no feedback as to what is going wrong.

jonathanrswift · 4 months ago

Happened to me, just interrupted with Esc, then prompted "continue", and everything was fine. Basically splitting into two outputs. CC should handle this automatically, or see the end of the output token limit approaching and handle it gracefully.

Mathijs-Wyder · 4 months ago

Same issue here...

sramazzina · 4 months ago

Same issue here? What's wrong?

amberyufangchiu · 4 months ago

same here

eduo · 4 months ago

I guess we get no response from Anthropic. In the meantime, Claude Code has burned my 5 hours session in two failed responses, each of which took over 30 minutes to fail.

<img width="1231" height="373" alt="Image" src="https://github.com/user-attachments/assets/a43077af-8e0b-43e3-9f06-35f0be80423e" />

I agree that if there are technical limitations and a response can't be provided, the tokens wasted should not be applied. It's not the same as if the user is misusing the agent but rather that the agent failing to respond is costing the user money. This makes no sense whatsoever.

sitjac · 4 months ago

Same problem here, could anyone clarify if there’s an option to increase the CLAUDE_CODE_MAX_OUTPUT_TOKENS limit through configuration?

<img width="521" height="555" alt="Image" src="https://github.com/user-attachments/assets/8a3b3540-0263-4782-b812-42d8b7425a2b" />

adelrzouga · 4 months ago

I’m experiencing the same issue here. I’m not sure if there’s a way to upvote this.

devakm · 4 months ago

Just ran into the same issue.

chaugan · 4 months ago

Same here. Switching the model to opus 4.5 solved it for me.

Sivakumar-finoli · 4 months ago

Switched to Codex plugin for VSCode after a week of struggle with Claude Sonnet 4.6 and getting work done at a much faster pace. Stopping my monthly subscription of Claude pro. Its goodbye unless I hit a bottleneck with Codex - fingers crossed.

itk22 · 4 months ago

I also encountered this, especially when using Sonnet 4.6. It's extremely frustrating.

sudoHackIn · 4 months ago

a have the same issue but event with website cloud version of claude code. It spent all 5 hour session without result with this error

cwenterprises · 4 months ago

Same issue. 40 minutes in and still thinking.

drewbug · 4 months ago

36 minutes, 46 seconds for me.

lsulliv · 4 months ago

I ran into this on Windows, but switched to using the cli on Ubuntu and in
Antigravity on Ubuntu and haven't run into it again.

On Fri, Feb 27, 2026, 08:44 drewbug @.***> wrote:

drewbug left a comment (anthropics/claude-code#24055) <https://github.com/anthropics/claude-code/issues/24055#issuecomment-3973642479> 36 minutes, 46 seconds for me. — Reply to this email directly, view it on GitHub <https://github.com/anthropics/claude-code/issues/24055#issuecomment-3973642479>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AGHWWQT2VHB43HDCZLDHLWD4OBQ5JAVCNFSM6AAAAACULIWOHOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTSNZTGY2DENBXHE> . You are receiving this because you are subscribed to this thread.Message ID: @.***>
molundb · 4 months ago

I have the same issue. Switching to Opus 4.6 seems to have improved it for now.

BingeBop · 4 months ago

Same issue here

ilaikim99 · 4 months ago

There's an env var that raises the output ceiling beyond 32k — and a thinkingEffort setting that frees up output space by reducing extended thinking tokens. Both approaches documented here: https://cacheoverflow.dev/blog/OihAEBhp

pat-CIMAR-UF · 4 months ago

I have been seeing the same error too for 2 days.
Claude Code is unusable because of this now.

samthebest · 4 months ago

This seems to be a recent thing (reddit agrees), like within the last week or so.

Some people are saying "any prompt with a complex task", while other are saying "even simple tasks". I think what is complex vs what is simple is highly subjective.

I've seemingly noticed an improvement in the quality of the responses. It feels to me like Claude has had a recent update, which has improved it's "reasoning" ability, but with quite extreme increase in time & cost.

(* "reasoning", LLMs cannot actually reason, they can only do System One)

Therefore I suggest: Clear simple modes:

  • "fast & dumb" - for mechanical refactors, just syntax manip
  • "Moderate" - for simple features, standard code monkey work
  • "Smart" - for algorithm design, debugging, writing and unit testing

In my company, we have a lot of complex algorithms, and waiting for Claude to give a (pretty nearly) correct solution in 30 minutes is WAY MORE VALUE than a completely wrong answer in 30 seconds. So I don't think this thread is a bug, but rather an "immature feature".

I think the key to a fair and transparent cost model is that when Claude fails to give an answer (either user cancels, or hits some limit) then we shouldn't be charged.

I'd also love to see some comms around this from Anthropic, like a YouTube video that explains why some prompts cause Claude to burn through tokens - like what is it actually doing under the hood? Because it doesn't actually output 32k tokens (in the form of code/response) - those tokens are in intermediate thought steps?

Interesting stuff.

tnorman42 · 4 months ago

I can't get past this error at all with my project now. It's only 10k LOC and every time I prompt it to fix a (pretty easy) bug, it just hangs for 10+ minutes and then gives this stupid useless CLAUDE_CODE_MAX_OUTPUT_TOKENS error. I've already hand-written the bug fix and Claude is still hung. Restarted conversations, compacted, updated CLAUDE.md to tell it not to read full file contents. Nothing works.

Xefan · 4 months ago

If it helps anyone I haven't had this bug since just after I commented last time. I've been purely using Opus 4.6 before, during, and after this bug so I don't think model selection matters per-se. What I did do is simply explain to Claude that it has this bug and so will need to think differently and perhaps break things up to get past it and this worked a charm. Once I got past the bug it hasn't resurfaced at all and I've been using the same session ever since (over a week).

Maybe I just got lucky ever since, but it's worth a try - just make Claude aware of the problem. If it pops up, interrupt Claude and tell it to pay attention to the error it received and try a different approach.

tnorman42 · 4 months ago
I can't get past this error at all with my project now. It's only 10k LOC and every time I prompt it to fix a (pretty easy) bug, it just hangs for 10+ minutes and then gives this stupid useless CLAUDE_CODE_MAX_OUTPUT_TOKENS error. I've already hand-written the bug fix and Claude is still hung. Restarted conversations, compacted, updated CLAUDE.md to tell it not to read full file contents. Nothing works.

FWIW, I finally managed to get past this (for now) by adding this to CLAUDE.md:

IMPORTANT

  • Do NOT try to read all the test files all at once! They are extremely exhaustive and wordy. Use regex, search, and other tools to read small parts of the tests as needed.

And then I asked it to refactor one of my very large unit test files into 4 separate files. This unit test had been complaining that it had too many tokens to read previously, which was probably contributing to this error.

mkuangdotcom · 4 months ago

I faced this issue to across Opus and Sonnet. Could try turning off "thinking mode", this helps for me.

kollhof · 4 months ago

New Claude user, just signed up to a pro subscription to evaluate claude code. First issue, auth outage today, so delayed in setting up VSCode extension. Finally got going, intermittent long thinking times and then repeated CLAUDE_CODE_MAX_OUTPUT_TOKENS errors in the chat, no partial responses or anything helpful. Then things worked again.

I will try the suggested settings.

<rant-to-vent>
Reached some subscription limit on day 1! Added funds for extra usage. Frustrating first experience, tbh.

Reached out to support (bot), which tried to explain to me why I should pay, as work had been done by their API and tokens have been consumed.

... I order a pizza online. The pizzeria goes off and processes my order, spends energy and time. At some point get notified that something went wrong, and the pizza cannot be delivered. But, I still need to pay!? ...

They are sending my inquiry off to a human.
</rant-to-vent>

sonewman · 4 months ago

Yeah, this just happened to me, seems my issue is linked. Claude was running for about 25 minutes, no output, but used my remaining 30% usage limit, so i'm done until 11pm now. - as mentioned in my issue. i gave codex the same problem via the copilot cli and it fixed it in less than 5 minutes

DaveyLovesCode · 4 months ago

Happening a lot lately. I think the model is just thinking itself to death

2001zhaozhao · 4 months ago

This is happening with Sonnet 4.6 with medium effort (not High) for some reason

NinjaCross · 4 months ago

I don't know if it helps, but this worked for me:

> I stopped you because you just encountered this error " API Error: Claude's response exceeded the 32000 output token maximum. To configure this behavior, set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable."

What should we do to prevent this ?

● The error happens when I try to generate too many changes in a single response. The fix is simple: we work one file at a time, not all at once.

  Here's how we'll proceed:

  1. I'll tell you which file I'm about to modify before touching it
  2. I'll edit/write it, then stop and wait for your confirmation
  3. You say "next" (or give feedback), and I move to the next file

  This also gives you a chance to review each change before I continue.
echo8134 · 4 months ago

I've had this issue too on Linux with either the env set to 64 or 128. Adjusting behaviour in the claude.md is not a solution for my use case (complex reverse engineering and binary exploitation).
This happens for subagent output as well as the main opus/sonnet if the limit is reached.

jmcarthur · 4 months ago

This has been happening to me since the day Opus 4.6 was announced. It's driving me insane.

DanielEskinazi · 4 months ago

This is happening to me non-stop on Claude Code as of today...

MMagneson · 4 months ago

Just had this happen, I just waited a bit and it continued by itself. Will report back if the resulting work was more flawed than expected.

DanjelRicci · 4 months ago

I've been encountering this bug too for the last 12 hours both with Opus 4.6 and Sonnet 4.6. Changing the environment variable didn't have any effect. It's always massively overthinking, right now it is unable to fix and understand its own code from yesterday.

af-01 · 4 months ago

Omg, it became unusable.

gabrix-dev · 4 months ago

The same thing happened to me twice in 2 different sessions in a row. Now seems fine.

tigwyk · 4 months ago

I have one project repo where I can reliably reproduce this behaviour in Claude Code/VS Code Extension. Unsure if it's corrupted context or something but I can't tell Claude to start any task in this project without thinking forever, getting CLAUDE_CODE_MAX_OUTPUT_TOKENS errors, and eventually exhausting my limit. Started happening as of a few days ago.

ivins · 4 months ago

Sonnet-4-6 has been regularly running into this over the last week. Intermittent though and sometimes it is able to recover on it's own.

Moorey79 · 4 months ago

Claude 4.6 does not respect the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.
When a response exceeds the default 8,000 token limit, the model retries repeatedly,
consuming tokens on each failed attempt without ever delivering output.

When generating a response that exceeds 8,000 tokens, Claude Code:

  1. Hits the limit and fails with: API Error: Claude's response exceeded the 8000 output token maximum
  2. Retries the same request automatically
  3. Fails again — repeatedly — burning tokens each time
  4. Never delivers output

The CLAUDE_CODE_MAX_OUTPUT_TOKENS variable is not respected by the model, so raising
it has no effect. Tokens are consumed by every failed retry.

## Evidence — Recent occurrences found in JSONL transcripts

| Session | Date | Failed attempts |
|---|---|---|
| Session 36f74999 | 06/03/2026 | 22 |
| Session 551e8d2a | 01/03/2026 | 10 |
| Subagent (session 36f74999) | 06/03/2026 | 2 |
| Subagent (session 551e8d2a) | 01/03/2026 | 1 |
| Total | | 35 |

All 35 occurrences confirmed by grepping local JSONL transcript files for
"exceeded the 8000 output token".

## Impact

35 API calls consumed tokens and produced no usable output. This represents a
meaningful cost to the user with zero value delivered.

3f6a · 4 months ago

I'm hitting this right now. On Claude Code Desktop for macOS.

API Error: Claude's response exceeded the 32000 output token maximum. To configure this behavior, set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.

I'm not even sure where I"m supposed to configure this setting. There is nothing in the settings of the app.

I could set an environment variable, but I think that would make sense if I were using the terminal Claude CLI, which I'm not here. My guess is that the desktop app doesn't see this environment variable.

venkateshdasarigt · 4 months ago

echo 'export CLAUDE_CODE_MAX_OUTPUT_TOKENS=128000' >> ~/.zshrc && echo "Added to ~/.zshrc" just add this command in terminal and after adding this command do this in your terminal source ~/.zshrc

3f6a · 4 months ago

@venkateshdasarigt Again, note that I am using the Claude Desktop app, for MacOS. Not the CLI.

venkateshdasarigt · 4 months ago

yes that works try it out on your root terminal

tim-hub · 4 months ago
CLAUDE_CODE_MAX_OUTPUT_TOKENS

The first url, the doc removed this settings in the odc

yurukusa · 4 months ago

The fix is in the error message itself — set the environment variable:

# Add to your shell profile (~/.bashrc, ~/.zshrc, etc.)
export CLAUDE_CODE_MAX_OUTPUT_TOKENS=128000

The default is 32,000 tokens. For complex tasks with Opus 4.6, especially ones requiring large code generation or multi-file changes, 32K can be hit. 128K gives plenty of headroom.

Quick test without permanent change:

CLAUDE_CODE_MAX_OUTPUT_TOKENS=128000 claude

Note: Higher output token limits mean Claude can produce longer responses, which uses more of your rate limit per response. If you're on Pro with Opus, this is a tradeoff — fewer long responses vs. more short ones within your rate window.

milankubin · 3 months ago
The fix is in the error message itself — set the environment variable: # Add to your shell profile (~/.bashrc, ~/.zshrc, etc.) export CLAUDE_CODE_MAX_OUTPUT_TOKENS=128000 The default is 32,000 tokens. For complex tasks with Opus 4.6, especially ones requiring large code generation or multi-file changes, 32K can be hit. 128K gives plenty of headroom. Quick test without permanent change: CLAUDE_CODE_MAX_OUTPUT_TOKENS=128000 claude Note: Higher output token limits mean Claude _can_ produce longer responses, which uses more of your rate limit per response. If you're on Pro with Opus, this is a tradeoff — fewer long responses vs. more short ones within your rate window.

Nope, this is not the fix.
Let me tell you why:

  1. Claude stuck forever on mock design write to file after session restart, "one-shot" and also tries to one-shot the write.
  2. Claude finished creating a mock design, but as it wanted to write Auto-compact hit, which then cascaded into using the remainder of my 5h limit.
  3. Prompted with "Continue" after 5h reset (0% usage)
  4. Seemed to be stuck on writing (usage about 18%)
  5. Interrupted and poked it with a message asking if it was stuck
  6. Replied: "Not stuck — I was about to write the full file. The last read just finished. Writing it now." (usage 28%)
  7. "Writing the new accounting page now."

API Error: Claude's response exceeded the 32000 output token maximum. To configure this behavior, set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.
(Usage now at 58%)

  1. Pasted error message, and asked to write in chunks.

(Usage now at 61%)

Final result: 4% usage could have been spent on writing if Claude would have written in chunks right away, or had calculated the (very sensible value of 32k max output tokens) as a blocker for writing in one-go

Instead: 61% usage spent on several attempts, trying to tell me that it's not stuck.

Problems:

  1. Forced interrupt highly normal user action after 10m stuck on one file write, when token count doesn't go up, nor does any output come up in ctrl+o
  2. Retry shouldn't happen.
  3. Claude should be aware of ENV var and should just write in chunks.

Calculating est. token output is zero cost. Claude should not ignore this value before attempting write.

  1. 32k token output limit is a very sensible value, as it prevents accidents from consuming all of the usage.
  2. This isn't a 'user directed accident' it's a model's choice how they should write when an ENV var is set to limit the output max.

<img width="1787" height="947" alt="Image" src="https://github.com/user-attachments/assets/3b63860a-c581-4496-843b-2ecc1957c5ed" />

milankubin · 3 months ago
Claude 4.6 does not respect the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable. When a response exceeds the default 8,000 token limit, the model retries repeatedly, consuming tokens on each failed attempt without ever delivering output. When generating a response that exceeds 8,000 tokens, Claude Code: 1. Hits the limit and fails with: API Error: Claude's response exceeded the 8000 output token maximum 2. Retries the same request automatically 3. Fails again — repeatedly — burning tokens each time 4. Never delivers output The CLAUDE_CODE_MAX_OUTPUT_TOKENS variable is not respected by the model, so raising it has no effect. Tokens are consumed by every failed retry. ## Evidence — Recent occurrences found in JSONL transcripts Session Date Failed attempts Session 36f74999 06/03/2026 22 Session 551e8d2a 01/03/2026 10 Subagent (session 36f74999) 06/03/2026 2 Subagent (session 551e8d2a) 01/03/2026 1 Total 35 All 35 occurrences confirmed by grepping local JSONL transcript files for "exceeded the 8000 output token". ## Impact 35 API calls consumed tokens and produced no usable output. This represents a meaningful cost to the user with zero value delivered.

Agree, see my post.
Final: Consumed 62% for what would have been a 4% of 5h usage (Pro).
So at normal rates (in promo 2x now) that would have been (124% vs what could have been 8%).

gknops · 3 months ago

I reverted Claude Code to 4.5 a few weeks ago and have not seen any issues since. ~/.claude/settings.json:

{
	"model": "claude-opus-4-5-20251101",
	"enabledPlugins": {
		"clangd-lsp@claude-plugins-official": true
	}
}

I'd love to see what 4.6 has to offer, but at least 4.5 behaves predictable and reasonable.

milankubin · 3 months ago
{ "model": "claude-opus-4-5-20251101", "enabledPlugins": { "clangd-lsp@claude-plugins-official": true } }

The config value is for CLAUDE_ (e.g. all models, incl Sonnet, inc 4.5, inc. haiku).

It could be the case that Opus 4.5 does respect the value, but it's not Opus specific.
My experience today was with Sonnet 4.6.

So either the "don't care about this config var" is baked into both values, or a client instruction set (claude code) on top of it is not enforcing it. Which means only a Claude Code specific version reversion could possibly mitigate it.

You probably haven't seen it, because it hasn't happened.
Unless you can find some value in the logs somewhere that says that it had a >32k token output + knowing the actual ENV var value being set.
That would be valuable information.

yurukusa · 3 months ago

/tmp/gh-comment-24055.md

paulocoutinhox · 3 months ago

<img width="516" height="176" alt="Image" src="https://github.com/user-attachments/assets/e1354f4c-703c-421a-8f85-675f1ad017fc" />

Now im getting this error everytime.

zhengchencai · 3 months ago

Same here, same API error was repeated 4 times and wasted the entire 5h pro usage.

yurukusa · 3 months ago

/tmp/gh-comment-24055.md

HoseinHashemi · 3 months ago

try /clear and then retry. It'll likely reset and your prompt goes through.

Moorey79 · 3 months ago

Hi Steve,​
Thank you for reaching out to our team.
We first want to provide you with our sincere apologies for the delay. We are working hard as a team to restore our typical response times. Also, thank you for taking the time to document your concerns regarding your experience with Claude.ai.
​We understand how frustrating this situation must have been, especially given the ways of impact you've described.
We take all feedback about Claude's performance and responses seriously and I want to address your concerns directly.
​I reviewed internally for any known issues that may be affecting usage in the month of March.
I can confirm that there have been a few internal instances that we have publicly post about and update here on our status page - including the bugs you have highlighted in your above email.
It appears from your ticket these may have influenced your sessions during the time period that you have reported on & the time frame in which your ticket was opened.
These issues have now been resolved and should not be affecting you any longer.

​​While we cannot provide financial compensation, reset usage limits or reinstate usage credits for instances where there has been service and output degradation, please know that we value your feedback.

We have recorded this outcome and feedback internally which will contribute to helping us in our ongoing efforts to improve Claude's performance and safety.​Again, we appreciate you bringing this to our attention and remain committed to developing and improving our model's quality and accuracy.
​Kind regards,

Isn't that lovely, they value my feedback. Not in a monetary value, but they get something out of it.

nicwn · 3 months ago
1. Claude stuck forever on mock design write to file after session restart, "one-shot" and also tries to one-shot the write. 1. Claude finished creating a mock design, but as it wanted to write Auto-compact hit, which then cascaded into using the remainder of my 5h limit. 2. Prompted with "Continue" after 5h reset (0% usage) 3. Seemed to be stuck on writing (usage about 18%) 4. Interrupted and poked it with a message asking if it was stuck 5. Replied: "Not stuck — I was about to write the full file. The last read just finished. Writing it now." (usage 28%) 6. "Writing the new accounting page now." API Error: Claude's response exceeded the 32000 output token maximum. To configure this behavior, set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable. (Usage now at 58%) 7. Pasted error message, and asked to write in chunks. (Usage now at 61%)

From "Continue" after 5h reset to API Error, 78% of current session was used! Am I using superpowers' brainstorming wrong?

ashwin-ant collaborator · 2 months ago

This was fixed in v2.1.42 — CLAUDE_CODE_MAX_OUTPUT_TOKENS is now respected up to 64K for Opus 4.6 instead of being clamped to 32000. If you're still seeing this in the latest version, please comment with your version and repro and we'll reopen.

milankubin · 2 months ago
This was fixed in v2.1.42 — CLAUDE_CODE_MAX_OUTPUT_TOKENS is now respected up to 64K for Opus 4.6 instead of being clamped to 32000. If you're still seeing this in the latest version, please comment with your version and repro and we'll reopen.
  1. You say for "Opus 4.6" so this is a model specific bug, that required a model specific fix? How do other models behave?

In my case I was using Sonnet 4.6, so we can infer from your post that for Sonnet 4.6 the issue remains open?

  1. What is the failsafe behavior in any case? since the symptoms (extra quota use) stemming from the behavior in case the model(s) attempt a 64k token write are multiplied without a hard-fail and change of direction (to write in chunks).

If you ask Sonnet or Opus explicitly and beforehand to write in chunks when the output is expected to exceed a certain threshold, they do just that. This seems like behavior that warrants enforcement into the model itself, rather than leaving it up to the user to decide.

firedintern · 2 months ago

I basically have the same issue as @milankubin , using Sonnet 4.6.

MaverickJason · 2 months ago

Sadly, I have the same issue too. Was using Sonnet 4.6.

ToxicShawn · 2 months ago

Issue still present in Sonnet 4.6 in code version 2.1.128. Errored out after it spent 35 minutes and it decided the first response would be 105K tokens. It really should be more cognizant of its max output tokens as default behavior.

lohyenshen · 2 months ago

encountered same issue as @milankubin using Sonnet 4.6,
claude version 2.1.129

Codetron · 2 months ago

I'm having the same issue:

API Error: Claude's response exceeded the 32000 output token maximum. To configure this behavior, set the
     CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.

After waiting 30 minutes, this error appears. When I try again, the same error appears, and then the rate limit is applied... So no way to use it.

ToxicShawn · 2 months ago

Wow so this occurred _even when_ the following was added to my CLAUDE.md globally and at the project level:

## Response Size

- Never produce a single response large enough to hit the 32,000 output token limit (`CLAUDE_CODE_MAX_OUTPUT_TOKENS` default). Exceeding it drops the entire response with no partial output, wasting the user's session quota and time.
- When a task involves multiple files (plan docs, several scripts, etc.), write one or two files per turn and stop. Do not chain large file writes in one response.
- If a single file would be large, write it and stop — do not follow it immediately with another large file.

It gets to 32k, pauses then continues, gets to 64k, pauses then continues past 100k. What the hell else am I supposed to do?

milankubin · 2 months ago
Wow so this occurred _even when_ the following was added to my CLAUDE.md globally and at the project level: `` ## Response Size - Never produce a single response large enough to hit the 32,000 output token limit (CLAUDE_CODE_MAX_OUTPUT_TOKENS default). Exceeding it drops the entire response with no partial output, wasting the user's session quota and time. - When a task involves multiple files (plan docs, several scripts, etc.), write one or two files per turn and stop. Do not chain large file writes in one response. - If a single file would be large, write it and stop — do not follow it immediately with another large file. `` It gets to 32k, pauses then continues, gets to 64k, pauses then continues past 100k. What the hell else am I supposed to do?

Strange, when tested I did see Opus do exactly what I told it, but this was explicitly prompt injected and then later in the session inferred ("since this is going to be a large write, I'll write it in chunks as per instruction" something akin) applied.

I do get a little anxious still by the behavior of the models (Sonnet too), it likes to gather a whole lot in batch before doing single writes. If nearing some form of limit (or if it pertains to a single file), this can result in this problematic behavior.
Either it can't write all before a session limit, loses cache, then loads all history back again (easy 20% instant extra use on next 5h session for Pro) or .. in case of a single large write this will lead to this behavior.

Now I don't have this issue a lot, since I try to keep individual files small per convention (always a good idea), for large plan files it can certainly become a problem.

Just have to be mindful while instructing, or create some tooling around it. Like some inspector agent to pre-inspect files and calculate est tokens on full rewrites, something like that, and catch them periodically. Maybe add some docstring comments to them or AGENTS.md in the directory.

forreggbor · 2 months ago

I have the same issue as of today. I've never seen this error before. Opus 4.7 plan mode

dwnsdp · 1 month ago

It just burnt all my tokens generating something then refused to output it... fuming.

mancuss · 1 month ago

same issue today after updating to v2.1.139

pmalacho-mit · 1 month ago

What an indictment of this industry. _"We've wasted your time. We've wasted our (server's) time. We've wasted your money. We've (probably) wasted our money. And there's nothing to show for it."_ The wastefulness is becoming unbearable.

cre8ivevision · 1 month ago

Extremely disappointed. Despite purchasing the pro plan for faster task completion, I encountered the same persistent error across multiple platforms (Claude native app, VS Code terminal, Claude VS Code extension, and Claude desktop app). This resulted in a significant loss of time, money, tokens, and momentum. The error message should clearly indicate the token restriction preventing large output files and suggest optimal solutions.

CXWorks · 1 month ago

Same as v2.1.145

jonathanMelly · 1 month ago

I had better results adding that to the prompt "split it into 3 parts so token limit of 32000 doesnt exceed"

pbasista · 1 month ago

Please remove the platform:windows label as this issue has nothing to do with Windows.

mikki1488-debug · 29 days ago
Пожалуйста, удалите метку platform:windows, так как эта проблема не связана с Windows.

I'm using Windows, and I just ran into a problem. I'm looking for a solution.

PsYcGoD · 5 days ago

The 32000 output token max is frustrating. Usually happens when Claude tries to dump massive amounts of generated content.

Workarounds:

  1. Ask Claude to generate in chunks rather than all at once
  2. For large outputs, write to file incrementally instead of building in memory
  3. Be explicit about length limits in your prompts

The root issue is often that input context is already huge (from prior command output), so Claude has less room for output.

PsYcGoD · 3 days ago

Context management tip: The 32K output limit often gets hit when Claude is working with large tool outputs already in context - verbose build logs, test suites, etc. compound the problem.

StdLogicTrig · 1 day ago

issue still exists in v2.1.199 with windows