How the agent loop works changedagent-sdk/agent-loop
Nearest release: v2.1.270, published 23 hours before this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Recorded here
Lines+3added
Lines−3removed
From line
52
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits28to this page, all time
The whole hunk
from line 52, old and new numbered
/
from line 52
5252 * `"init"`: session metadata for the run. When a `SessionStart` or `Setup` hook runs during session startup, its [hook lifecycle messages](/docs/en/agent-sdk/typescript#sdkhookstartedmessage) arrive before the `init` message
5353 * `"compact_boundary"`: fires after [compaction](#automatic-compaction)
5454 * `"informational"`: plain-text status banners from the loop
55 * `"worker_shutting_down"`: the loop will end after the current turn because the host is exiting or Remote Control disconnected
55 * `"worker_shutting_down"`: the host is exiting or Remote Control disconnected
5656
5757 In TypeScript, each subtype other than `"init"` is its own type in the [`SDKMessage` union](/docs/en/agent-sdk/typescript#sdkmessage) rather than a subtype of `SDKSystemMessage`.
5858* **`AssistantMessage`:** emitted for each content block in Claude's responses, including the final text-only one. Each carries a single content block, such as text or a tool call, and the messages from one response share a message ID.
from line 212
212212| `"xhigh"` | Extended reasoning depth | Coding and agentic tasks on the [models that support it](/docs/en/model-config#adjust-effort-level) |
213213| `"max"` | Maximum reasoning depth | Multi-step problems requiring deep analysis |
214214
215If you don't set `effort`, both SDKs leave the parameter unset and defer to the model's default behavior.
215If you don't set `effort`, Claude Code resolves the effort level itself, in the order [Adjust effort level](/docs/en/model-config#adjust-effort-level) describes.
216216
217217<Note>
218218 `effort` trades latency and token cost for reasoning depth within each response. [Extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) is a separate feature that produces `thinking` blocks in the output, and the `display` field on `ThinkingConfig` for [Python](/docs/en/agent-sdk/python#thinkingconfig) or [TypeScript](/docs/en/agent-sdk/typescript#thinkingconfig) controls whether you receive their text. They are independent: you can set `effort: "low"` with extended thinking enabled, or `effort: "max"` without it.
from line 315
315315| `success` | Claude finished the task normally | Yes |
316316| `error_max_turns` | Hit the `maxTurns` limit before finishing | No |
317317| `error_max_budget_usd` | Hit the `maxBudgetUsd` limit before finishing | No |
318| `error_during_execution` | An error interrupted the loop (for example, an API failure or cancelled request) | No |
318| `error_during_execution` | An error interrupted the loop (for example, a cancelled request) | No |
319319| `error_max_structured_output_retries` | No valid structured output was produced within the configured retry limit: every attempt failed validation, or a model fallback retracted the completed output with no successful retry | No |
320320
321321The `result` field holds the final text output and is only present on the `success` variant, so always check the subtype before reading it.
No line in this hunk matches that.