Create

Sign in to ReadmeX

or

How we handle your data: Privacy Policy

ReadmeX

Your AI reading companion

What would you like to catch up on?

Pick a briefing, or ask your own question.

Your community and people briefings stay personal to you.

Story

Recovering a Claude Code session that exceeded its 1M-token limit

AI summary

A firsthand account describes a Claude Code session whose requests all failed with a 400 error: 930,665 message tokens plus a 128,000-token completion allowance exceeded the deepseek-v4-pro limit of 1,048,576 tokens. The author notes that /compact also returned 400, because it sends the full conversation to the model rather than truncating locally, and attributes the failure to three overlapping causes: the hard model limit, an auto-compact window set to the full 1M with no headroom, and /compact needing the full transcript. The suggested recovery order is to exit and relaunch with claude --resume and a reduced 65,536-token output allowance, then /compact immediately, and only then /clear if 400 persists, since session JSONL files and memory files survive. Prevention settings are an 800,000-token auto-compact window and a 65,536 output allowance, which take effect only for newly started processes and can be checked with /context. The session ran on Claude Code 2.1.308 with deepseek-v4-pro on 2026-11-02; the author notes context-management behavior may change across versions.

In-depth insight

The report documents a concrete recovery and configuration workflow for long Claude Code sessions, including that the output reservation must be reduced before /compact can work, and that context can be rebuilt from retained JSONL, memory files, and project documents.

先说结论:按这个顺序救,别一上来就 /clear

1. 退出进程 → claude --resume 重开(带上调小的输出预留)
2. 重开后立刻 /compact
3. 还是 400 → /clear,然后靠重建文档接续(会话 JSONL 不会丢)

下面是一次真实事故的完整复盘:报错原文、为什么 /compact 也救不了、怎么预防。

事故现场

跑着一个长任务的 Claude Code 会话,突然所有请求都挂:

API Error: 400 This model's maximum context length is 1048576 tokens.
However, you requested 1058665 tokens (930665 in the messages, 128000 in the completion).

#Claude Code 2.1.308#deepseek-v4-pro

Original · 4 min readRead the original
Group chat

No comments yet. Start the conversation.