Follow Discord
Sweep 22 Oct 2026 · 21:04Z Build v2.1.309 528 read Stable v2.1.308 Latest v2.1.309 Next v2.1.309 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · claude-code

Agent SDK reference - TypeScript changedagent-sdk/typescript

Nearest release: v2.1.293, published 9 hours after 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 7 Oct 2026 07:30 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 7 Oct 2026 07:37 UTC.

Upstream edited
Recorded here
Lines+9added
Lines−4removed
From line 156 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits114to this page, all time

The whole hunk

from line 156, old and new numbered
/
lines

This page is larger than the 256 KiB this site keeps, so one side of the diff below stops where the stored text does.

from line 156
156156 console.error("Claim failed:", error.message);
157157});
158158 
159for await (const message of claimedQuery) {
160 console.log(message);
159try {
160 for await (const message of claimedQuery) {
161 console.log(message);
162 }
163} catch (error) {
164 // After a refused claim, the claimed query throws once it has yielded the error result
165 console.error(`Session ended with an error: ${error}`);
161166}
162167```
163168 
from line 749
744749 
745750`options.cwd` is required. A claim can also set `additionalDirectories`, `model`, `permissionMode`, `maxThinkingTokens`, a flag-settings overlay in `settings`, `appendSystemPrompt`, `title`, `agents`, and per-session tokens in `env`.
746751 
747Claude Code can refuse a claim, for example for a folder that doesn't exist or one whose project settings set `env`, `agent`, or `model`. When `claimed` rejects with a message that starts with `option_not_applied`, the session is running without the `model` or `maxThinkingTokens` you asked for. After any other rejection your prompt hasn't run, so start the session with `query()` instead.
752Claude Code can refuse a claim, for example for a folder that doesn't exist or one whose project settings set `env`, `agent`, or `model`. After a refusal, a prompt that `claim()` already sent gets an error result whose text starts with `not_claimed`, and the returned query then throws. Wrap the query's loop in a try block to continue past the throw. When `claimed` rejects with a message that starts with `option_not_applied`, the session is running without the `model` or `maxThinkingTokens` you asked for. After any other rejection your prompt hasn't run, so start the session with `query()` instead.
748753 
749754### `SDKControlInitializeResponse`
750755 
from line 4974
49694974 | { type: "disabled" }; // No extended thinking
49704975```
49714976 
4972The optional `display` field controls whether thinking text is returned `"summarized"` or `"omitted"`. On Claude Opus 4.7 and later, the API default is `"omitted"`, so set `"summarized"` to receive thinking content in `thinking` blocks. Claude Code doesn't send `display` to Amazon Bedrock or Google Cloud's Agent Platform, so on those providers Opus 4.7 and later return empty `thinking` blocks even when you set `display` to `"summarized"`.
4977The optional `display` field controls whether thinking text is returned `"summarized"` or `"omitted"`. On Claude Opus 4.7 and later, the API default is `"omitted"`, so set `"summarized"` to receive thinking content in `thinking` blocks. Claude Code leaves `display` out of requests to some providers, such as Amazon Bedrock and Google Cloud's Agent Platform. On those providers, Opus 4.7 and later return empty `thinking` blocks even when you set `display` to `"summarized"`.
49734978 
49744979### `SpawnedProcess`
49754980 
from line 5374
53695374 
53705375A turn's `idle` message and its `result` message can arrive in either order. To change whether `idle` waits for background work such as a background subagent or a [workflow](/docs/en/workflows) run, see [`CLAUDE_CODE_BG_TASKS_REPORT_RUNNING`](/docs/en/env-vars#variables).
53715376 
5372```typescript theme={null}
5373type SDKSessionStateChangedMessage = {
5374 type: "system";
5375 subtype: "session_state_changed";
5376 state: "idle" | "running" | "requires_action";
5377 uuid: UUID;
5378 session_id: string;
5379};
5380```
5381 
5382### `SDKFilesPersistedEvent`
5383 
5384Emitted when file checkpoints are persisted to disk.
5385 
5386```typescript theme={null}
5387type SDKFilesPersistedEvent = {
5388 type: "system";
5389 subtype: "files_persisted";
5390 files: { filename: string; file_id: string }
5377```typescript theme={nu
Feedback