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.290, 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 5 Oct 2026 21:14 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 5 Oct 2026 21:37 UTC.

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

### `SDKSessionStateChangedMessage`

The whole hunk

from line 5357, 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 5357
53575357};
53585358```
53595359 
5360### `SDKSessionStateChangedMessage`
5361 
5362Emitted when Claude Code reports the session's state. To receive these messages, set [`CLAUDE_CODE_EMIT_SESSION_STATE_EVENTS=1`](/docs/en/env-vars#variables). Claude Code can report the same state more than once, so read a message as the session's current state rather than as a transition.
5363 
5364The `state` field carries one of these values:
5365 
5366* `running`: the session is working.
5367* `idle`: Claude Code is waiting for your next prompt.
5368* `requires_action`: the session is blocked on an answer to a request it sent your host, such as a permission prompt.
5369 
5370A 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).
5371 
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 
53605382### `SDKFilesPersistedEvent`
53615383 
53625384Emitted when file checkpoints are persisted to disk.
from line 5407
53855407 resetsAt?: number;
53865408 utilization?: number;
53875409 errorCode?: "credits_required";
5388 canUserPurchaseCredits?: boolean;
5389 hasChargeableSavedPaymentMethod?: boolean;
5390 };
5391 uuid: UUID;
5392 session_id: string;
5393};
5394```
5395 
5396When `errorCode` is `"credits_required"`, the rejection is from a claude.ai subscription whose included usage is exhausted, and the session cannot continue until the user buys usage credits. `canUserPurchaseCredits` indicates whether the authenticated user can buy credits for the account, and `hasChargeableSavedPaymentMethod` indicates whether a saved payment method is on file. All three fields are absent on rate-limit events that are not credits-required rejections. Requires Claude Code v2.1.181 or later.
5397 
5398### `SDKLocalCommandOutputMessage`
5399 
5400Claude Code doesn't emit this message type. When you send a command such as `/context` or `/usage` as a prompt, its output arrives as an [`SDKAssistantMessage`](#sdkassistantmessage).
5401 
5402```typescript theme={null}
5403type SDKLocalCommandOutputMessage = {
5404 type: "system";
5405 subtype: "local_command_output";
5406 content: string;
5407 uuid: UUID;
5408 session_id: string;
5409};
5410```
5411 
5412### `SDKCommandsChangedMessage`
5413 
5414Emitted when the set
5410 canUserPurchaseCredits?:
Feedback