Troubleshoot the Agent SDK changedagent-sdk/troubleshooting
Nearest release: v2.1.326, published 3 hours before upstream edited the page. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Upstream edited this page at 16 Nov 2026 21:51 UTC, give or take a minute or two: the time comes from Anthropic’s own sitemap rather than from a commit. This site recorded the change at 16 Nov 2026 22:07 UTC.
Upstream edited
Recorded here
Lines+43added
Lines−5removed
From line
1
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits15to this page, all time
## Streaming input ### Operation aborted ### Prompt stream failed; closing stdin ### Image could not be processed
The whole hunk
from line 1, old and new numbered
/
from line 1
11# Troubleshoot the Agent SDK
22
3> Fix Agent SDK errors: the Claude Code CLI fails to start or exits, a tool message is too large, or a result arrives without structured output.
3> Fix Agent SDK errors: the Claude Code CLI fails to start or exits, your prompt generator throws, a tool message is too large, or structured output is missing.
44
5This page covers Agent SDK errors in CLI startup, CLI process exit, large tool calls and results, and structured outputs. Entries on this page are keyed to the error you see. Each entry names the cause and what to do.
5This page covers Agent SDK errors in CLI startup, CLI process exit, large tool calls and results, streaming input, and structured outputs. Entries on this page are keyed to the error you see. Each entry names the cause and what to do.
66
7Symptoms tied to a feature, such as a hook not firing or a skill not being used, have a troubleshooting section on that feature's page. The table names the section or page that covers each symptom:
7Symptoms tied to a feature, such as a hook not firing or a skill not being used, have a troubleshooting section on that feature's page. Look up your symptom in this table to find the section or page that covers it:
88
99| Symptom | Go to |
1010| :- | :- |
from line 17
1717| An agent that works on your machine fails in a deployed service or container | [Troubleshoot deployment failures](https://code.claude.com/docs/en/agent-sdk/hosting.md#troubleshoot-deployment-failures) |
1818| `Not logged in`, `Invalid API key`, `API Error`, `429`, `There's an issue with the selected model` | [Error reference](https://code.claude.com/docs/en/errors.md#find-your-error) |
1919| `CLINotFoundError`, `CLIConnectionError`, `ProcessError`, `Claude Code process exited with code N`, `Claude Code returned an error result`, `CLIJSONDecodeError`, `structured_output` is `None` | [CLI startup](#cli-startup), [CLI process exit](#cli-process-exit), [Large tool calls and results](#large-tool-calls-and-results), and [Structured outputs](#structured-outputs) on this page |
20| `Operation aborted`, `Claude Code process aborted by user`, `Prompt stream failed; closing stdin`, or a Python `query()` loop that stops, with no exception, before all your messages are answered | [Streaming input](#streaming-input) on this page |
21| `Image could not be processed` | [Image could not be processed](#image-could-not-be-processed) on this page |
2022
2123## CLI startup
2224
from line 161
159161
1601621. If you hold a `ClaudeSDKClient` open, call `disconnect()`. The client receives no more messages after this error, but Claude Code keeps running and can still make changes.
1611632. Start a new `query()` or `ClaudeSDKClient` with the larger limit and [`continue_conversation=True`](https://code.claude.com/docs/en/agent-sdk/sessions#continue-resume-and-fork), which picks the most recent session in the working directory. To pick a specific session, set `resume` to `data["session_id"]` from the init [`SystemMessage`](https://code.claude.com/docs/en/agent-sdk/python#systemmessage).
164
165## Streaming input
166
167### Operation aborted
168
169In TypeScript, your `for await` loop over `query()` throws one of these messages as an `AbortError`. Either one means the query was aborted:
170
171```text theme={null}
172Operation aborted
173Claude Code process aborted by user
174```
175
176Check for these causes:
177
178* **Your code aborted the query**: if your code calls `abort()` on the `AbortController` you passed as the [`abortController`](https://code.claude.com/docs/en/agent-sdk/typescript#options) option, the loop throws one of these errors. If you didn't intend the abort, check where your code calls `abort()`.
179* **Your async generator threw**: the error doesn't include your generator's own error message. To see that message, wrap the generator's body in `try`/`catch`, log the caught error, and rethrow it. Then fix the error you logged.
180
181### Prompt stream failed; closing stdin
182
183In Python, when the async generator you passed to the `query()` function raises an exception, your `async for` loop over `query()` ends with no exception. The SDK logs this line at `ERROR` level. If you haven't configured logging, Python prints the line to stderr:
184
185```text theme={null}
186Prompt stream failed; closing stdin: <your exception's message>
187```
188
189To see the exception's traceback, wrap the generator's body in `try`/`except`. Log the exception with its traceback and raise it again. Then fix the exception you logged.
190
191### Image could not be processed
192
193When an image block in your message has no `source` object, no error reaches your code. Claude receives this text note in place of the image:
194
195```text theme={null}
196[Image could not be processed: image block has no source object]
197```
198
199Claude answers without the image. Check that each image block has a `source` object, as in [Send a follow-up with an image](https://code.claude.com/docs/en/agent-sdk/streaming-vs-single-mode.md#send-a-follow-up-with-an-image).
162200
163201## Structured outputs
164202
No line in this hunk matches that.