What you will be able to do
- Sort a Claude Code error message into its category before deciding what to do
- Predict which failures Claude Code retries on its own and which need action from you
- Recover a session from autocompact thrashing without losing the investigation
- Get past a refusal and find a stuck or looping agent in a multi-agent session
1.Sort the error into a category before acting
A Claude Code error message usually tells you which category it belongs to, and the category decides your next move. The error reference groups messages into server errors, usage limits, authentication, network, request errors, command-line errors, plugin errors and tool errors. Deciding the category first keeps you from the most expensive mistake: retrying something that will never succeed, or rewriting a prompt to fix what was really an outage.
| Category | Example message | What it tells you |
|---|---|---|
| Server errors | API Error: Repeated 529 Overloaded errors | Anthropic-side trouble; often transient |
| Usage limits | You've hit your session limit | Your quota or spend cap is used up; retrying won't help until it resets |
| Authentication | Not logged in · Please run /login | Credentials are missing or expired; the message names the fix |
| Network | Unable to connect to API | The path between you and the API is broken: connectivity, proxy or certificates |
| Request errors | Context limit reached · /compact or /clear to continue | The request itself has to change before it can succeed |
| Command-line errors | --bg and --print conflict | The way Claude Code was invoked is wrong; fix the flags |
The HTTP status codes underneath follow the same split. A 529 overloaded_error means the API is temporarily overloaded. A 429 rate_limit_error can mean a rate limit or a reached spend cap. A 400 invalid_request_error means the request's format or content is wrong. If a failure persists and you need support, include the request ID from the error: every API response carries one.
Checkpoint 1 of 6· Match them up
Match each Claude Code error message to what its category tells you to do next.
Tap a term, then the definition that fits it.
The category decides the next move. A 529 overload is a server error and often passes. A session limit is a usage limit, and retrying fails until it resets. A context limit is a request error, so the input has to change (for example with /compact or /clear). A connection failure points to the network. A flag conflict is a command-line error.
“Context limit reached · /compact or /clear to continue | Request errors”Source: code.claude.com
Sources1
2.What Claude Code retries for you, and what it won't
Claude Code retries failures that are transient and that happen before any useful output exists. Server errors, overloaded responses and request timeouts that arrive before any of Claude's response has streamed are retried with backoff. So are dropped connections, including one broken because your computer went to sleep. Temporary 429 throttles are retried too. A message like Waiting for API response · will retry in means this is already happening, and you should wait instead of intervening.
Some retries are deliberately capped:
- Stalled stream: a response stream that stalls before any response arrives is aborted and streamed again at most once.
- Error after thinking: a server error that arrives after Claude finishes thinking but before any text or tool call is retried up to two times.
- Content filter: a response stopped by the output content filter is re-sent once. A second block shows
Output blocked by content filtering policy.
Everything that needs a change from you stays failed. A spend-cap 429 has no retry-after header and keeps failing until access resumes. Authentication and request errors name their own fix, such as /login or /compact or /clear. Waiting longer won't clear either kind.
Checkpoint 2 of 6· Check yourself
Your session shows an error and you're deciding whether to step in or let Claude Code handle it. Which of these situations will Claude Code recover from by itself if you just wait?
A connection broken by sleep counts as a dropped connection, which is transient, so Claude Code retries it with backoff. The content-filter re-send happens only once, so a second block is final. Context-limit and login errors name a fix that you have to apply, and waiting won't clear them.
“Claude Code detects was broken by your computer going to sleep partway through a request. Claude Code counts it as a dropped connection”Source: code.claude.com
3.Recovering from context pressure and autocompact thrashing
Compaction summarizes earlier conversation history to free room in the context window; the mechanics are in Compaction (server-side and client-side SDK). Compaction can fail in a loop. If the context fills back to the limit straight after compacting, three times in a row, Claude Code stops with an "Autocompact is thrashing" error instead of burning more API calls. That error tells you something specific: whatever keeps refilling the window is still in the conversation, so compacting or retrying again won't help.
The fix is to stop the refill at its source. A typical case is reading a 40,000-line log in one go. Work through these steps in order:
- Ask Claude to read the oversized file in smaller chunks, such as a specific line range or function.
- Run
/compactwith a focus that drops the large output, for example/compact keep only the plan and the diff. - Move the large-file work to a subagent, so it runs in a separate context window.
- Run
/clear, but only if the earlier conversation is no longer needed.
Each step costs something different, so check what you are giving up. A focused /compact keeps only what you name, and anything else, like earlier hypotheses, survives only as summary. /clear drops the whole conversation, which is a poor trade in the middle of an investigation where the reasoning so far still matters. After recovering, check /context. If Messages is the largest row, some output is refilling the window again. If the other rows together are larger, what loads at startup leaves too little room, so trim it. /compact can also return Not enough messages to compact. even when the context is full, if a single large paste filled it.
Checkpoint 3 of 6· Check yourself
Midway through an investigation, you ask Claude Code to read a 40,000-line service log in one go. The session then stops with "Autocompact is thrashing." You still need the reasoning built up so far. What should you do first?
Thrashing means the input that refills the window is still in the conversation, so compacting again or waiting won't help. Reading the log in chunks stops the refill at its source. /clear also throws away the reasoning you still need, so it is the last step and only for when the earlier conversation no longer matters.
“Ask Claude to read the oversized file in smaller chunks, such as a specific line range or function, instead of the whole file”Source: code.claude.com
Checkpoint 4 of 6· Exam question
During a long debugging session, Claude Code raises "Autocompact is thrashing: the context refilled to the limit..." immediately after automatic compaction completes, and it stops retrying. The team was asking Claude to read an entire 40,000-line production log file to find the root cause of an outage. What is the most effective way to recover and continue the investigation?
Correct answer: B — Ask Claude to read the log file in smaller chunks, such as a specific line range, or delegate the analysis to a subagent instead.
- A. Incorrect. CLAUDE_CODE_MAX_RETRIES governs retries of failed API requests, not the compaction-thrashing loop. Thrashing happens because the file itself refills the context after each compaction, so retrying compaction more times does not solve the underlying problem.
- B. Correct. Auto-compaction succeeded but the oversized file output immediately refilled the context window several times in a row, so Claude Code stopped retrying to avoid wasted API calls. Reading the file in smaller chunks or moving the work to a subagent's separate context window is the documented recovery path.
- C. Incorrect. Disabling auto-compaction removes the safeguard that prevents the context window from overflowing, so it would make the thrashing problem worse, not better, since the full log would still need to fit in context.
- D. Incorrect. This is more drastic than necessary and discards useful investigation context. The documented recovery steps are to chunk the file, use a targeted /compact, or delegate to a subagent, not to abandon the conversation entirely.
4.Recovering a session that stalled on a refusal
A refusal blocks the conversation from the turn that triggered it. Why the model refuses is covered under built-in safety classifiers and refusal fallback. Recovering means getting back to a point before that turn. Press Esc twice or run /rewind to return to a checkpoint before the triggering turn, then rephrase or take a different approach. If you can't tell which turn caused it, /clear starts a fresh conversation in the same project. The old conversation stays on disk and is still available in /resume.
Headless runs need a different path, because rewind isn't available under -p. Retry with a rephrased prompt in a new session without --continue. Policy checks vary by model, so --model can sometimes help as well. Sometimes the trigger is in a customization rather than your prompt. If the message shows Details: [reasoning_extraction], look for an instruction telling Claude to write out its reasoning verbatim, which may sit in CLAUDE.md, a skill or an MCP tool description. To confirm, send the same prompt in a claude --safe-mode session. After you change the customization, start a new session.
Checkpoint 5 of 6· Check yourself
A refusal arrives with "Details: [reasoning_extraction]". You suspect the trigger is a customization, not your prompt. Which step confirms that?
Safe mode leaves CLAUDE.md, skills, plugins, hooks and MCP servers unloaded. If the same prompt goes through there, a customization caused the refusal, such as an instruction to write out reasoning verbatim. Rewinding, /clear and --continue all still load the same customizations, so they can't tell you whether one of them is the cause.
“Restart with claude --safe-mode to check whether a plugin, MCP server, or hook is the source. It disables all customizations for the session”Source: code.claude.com
Sources2
5.Finding the stuck or looping agent in a multi-agent session
When a multi-agent session stops making progress, first find which agent is stuck before deciding what to do. How spans and traces work is covered under reading a trace: spans across a run and its subagents. Claude Code tags each claude_code.tool OTEL span with agent_id and parent_agent_id, and background subagent spans nest under the Agent tool span that dispatched them. Follow those IDs down the tree. The agent whose span stays open, or that keeps producing the same tool calls, is the one stuck or looping.
You can see the same tree without a tracing backend. /agents shows the nested subagent tree as work fans out, with a descendant count on each row and a path back to main. Runaway nesting has a ceiling: subagent chains are capped at five levels deep. Once you've found the stuck agent, press Ctrl+C to try to cancel the current operation. If the session doesn't respond, close the terminal and restart.
Checkpoint 6 of 6· Check yourself
The /agents tree points to one subagent that keeps making the same tool calls. You press Ctrl+C to cancel the current operation, but the session stays frozen and doesn't respond to input. What is the next step?
Ctrl+C is the first attempt to cancel. If the session still doesn't respond, the fallback is to close the terminal and restart. Rewind and /compact need a session that responds to input. Automatic retries cover transient API failures, not an agent stuck in a loop.
“If unresponsive, you may need to close the terminal and restart”Source: code.claude.com
Sources
(5)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.https://platform.claude.com/docs/en/api/errorsOfficial docs
“529 - overloaded_error: The API is temporarily overloaded.”
↩︎ Sort the error into a category before acting“When contacting support about a specific request, include this ID to help quickly resolve your issue.”
↩︎ Sort the error into a category before acting“A tier spend-cap 429 has no retry-after header and keeps failing until access resumes”
↩︎ What Claude Code retries for you, and what it won't“A tier spend-cap 429 has no retry-after header and keeps failing until access resumes”
↩︎ Exam trap 2 - 2.https://code.claude.com/docs/en/errorsOfficial docs
“Server errors, overloaded responses, and request timeouts that arrive before any of Claude’s response has streamed.”
↩︎ What Claude Code retries for you, and what it won't“Claude Code aborts the stalled connection and streams the request again at most once.”
↩︎ What Claude Code retries for you, and what it won't“If you can’t identify which turn caused it, run /clear to start a fresh conversation in the same project.”
↩︎ Recovering a session that stalled on a refusal“Your previous conversation is preserved on disk and remains available in /resume.”
↩︎ Recovering a session that stalled on a refusal“Policy checks vary by model, so switching to a different model with --model may also resolve the refusal in some cases.”
↩︎ Recovering a session that stalled on a refusal“Context limit reached · /compact or /clear to continue | Request errors”
↩︎ Checkpoint“Temporary 429 throttles, but not a gateway’s spend-limit 429, which isn’t a throttle”
↩︎ Prediction“Claude Code detects was broken by your computer going to sleep partway through a request. Claude Code counts it as a dropped connection”
↩︎ Checkpoint - 3.https://code.claude.com/docs/en/changelogOfficial docs
“now detects when context refills to the limit immediately after compacting three times in a row and stops with an actionable error”
↩︎ Recovering from context pressure and autocompact thrashing“Added agent_id and parent_agent_id attributes to claude_code.tool OTEL spans”
↩︎ Finding the stuck or looping agent in a multi-agent session“now detects when context refills to the limit immediately after compacting three times in a row and stops with an actionable error”
↩︎ Exam trap 1 - 4.https://code.claude.com/docs/en/troubleshootingOfficial docs
“Ask Claude to read the oversized file in smaller chunks, such as a specific line range or function, instead of the whole file”
↩︎ Recovering from context pressure and autocompact thrashing“Move the large-file work to a subagent so it runs in a separate context window”
↩︎ Recovering from context pressure and autocompact thrashing“If it returns Not enough messages to compact., the conversation has too few turns to summarize”
↩︎ Recovering from context pressure and autocompact thrashing“Press Ctrl+C to attempt to cancel the current operation”
↩︎ Finding the stuck or looping agent in a multi-agent session“Restart with claude --safe-mode to check whether a plugin, MCP server, or hook is the source. It disables all customizations for the session”
↩︎ Checkpoint“If unresponsive, you may need to close the terminal and restart”
↩︎ Checkpoint - 5.https://code.claude.com/docs/en/whats-new/2026-w24Official docs
“Subagent chains are capped at five levels deep to prevent runaway concurrent trees.”
↩︎ Finding the stuck or looping agent in a multi-agent session