You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/claude-code/agent-sdk/structured-outputs.md
+11-5Lines changed: 11 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -140,6 +140,8 @@ Instead of writing JSON Schema by hand, you can use [Zod](https://zod.dev/) (Typ
140
140
141
141
The example below defines a schema for a feature implementation plan with a summary, list of steps (each with complexity level), and potential risks. The agent plans the feature and returns a typed `FeaturePlan` object. You can then access properties like `plan.summary` and iterate over `plan.steps` with full type safety.
142
142
143
+
The SDK validates schemas with JSON Schema draft-07, so schemas that declare a newer version are rejected. Zod targets draft 2020-12 by default, so pass `target: "draft-7"` when converting your schema.
144
+
143
145
<CodeGroup>
144
146
```typescript TypeScript theme={null}
145
147
import { z } from"zod";
@@ -161,8 +163,8 @@ The example below defines a schema for a feature implementation plan with a summ
161
163
162
164
typeFeaturePlan=z.infer<typeofFeaturePlan>;
163
165
164
-
// Convert to JSON Schema
165
-
const schema =z.toJSONSchema(FeaturePlan);
166
+
// Convert to JSON Schema using the draft-07 target the SDK expects
@@ -257,7 +259,7 @@ The example below defines a schema for a feature implementation plan with a summ
257
259
The `outputFormat` (TypeScript) or `output_format` (Python) option accepts an object with:
258
260
259
261
*`type`: Set to `"json_schema"` for structured outputs
260
-
*`schema`: A [JSON Schema](https://json-schema.org/understanding-json-schema/about) object defining your output structure. You can generate this from a Zod schema with `z.toJSONSchema()` or a Pydantic model with `.model_json_schema()`
262
+
*`schema`: A [JSON Schema](https://json-schema.org/understanding-json-schema/about) object defining your output structure. You can generate this from a Zod schema with `z.toJSONSchema(schema, { target: "draft-7" })` or a Pydantic model with `.model_json_schema()`
261
263
262
264
The SDK supports standard JSON Schema features including all basic types (object, array, string, number, boolean, null), `enum`, `const`, `required`, nested objects, and `$ref` definitions. For the full list of supported features and limitations, see [JSON Schema limitations](https://platform.claude.com/docs/en/build-with-claude/structured-outputs#json-schema-limitations).
263
265
@@ -383,7 +385,7 @@ The schema includes optional fields (`author` and `date`) since git blame inform
383
385
384
386
## Error handling
385
387
386
-
Structured output generation can fail when the agent cannot produce valid JSON matching your schema. This typically happens when the schema is too complex for the task, the task itself is ambiguous, or the agent hits its retry limit trying to fix validation errors. It can also happen without any validation failure: a [model fallback](/en/model-config#automatic-model-fallback) can retract an already-completed output mid-stream, and if no retry replaces it the run ends with the same error. Check the `errors`field on the result message to tell the two causes apart before debugging your schema.
388
+
Structured output generation can fail when the agent cannot produce valid JSON matching your schema. This typically happens when the schema is too complex for the task, the task itself is ambiguous, or the agent hits its retry limit trying to fix validation errors. It can also happen without any validation failure: a [model fallback](/en/model-config#automatic-model-fallback) can retract an already-completed output mid-stream, and if no retry replaces it the run ends with the same error. Check the `errors`list on the result message to tell the two causes apart before debugging your schema.
387
389
388
390
When an error occurs, the result message has a `subtype` indicating what went wrong:
389
391
@@ -392,7 +394,7 @@ When an error occurs, the result message has a `subtype` indicating what went wr
392
394
|`success`| Output was generated and validated successfully |
393
395
|`error_max_structured_output_retries`| No valid output remained after multiple attempts (validation failures, or a model-fallback retraction with no successful retry) |
394
396
395
-
The example below checks the `subtype` field to determine whether the output was generated successfully or if you need to handle a failure:
397
+
A result can also end with subtype`success` but no `structured_output` value, for example when the run completes without the agent producing a structured output. Treat that case as a failure as well. The example below treats a result as successful only when the `subtype` is `success` and `structured_output` is present, and handles every other result as a failure:
396
398
397
399
<CodeGroup>
398
400
```typescript TypeScript theme={null}
@@ -423,6 +425,8 @@ The example below checks the `subtype` field to determine whether the output was
Copy file name to clipboardExpand all lines: content/en/docs/claude-code/memory.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -383,6 +383,8 @@ This limit applies only to `MEMORY.md`. CLAUDE.md files are loaded in full regar
383
383
384
384
Topic files like `debugging.md` or `patterns.md` are not loaded at startup. Claude reads them on demand using its standard file tools when it needs the information.
385
385
386
+
The main conversation's auto memory isn't loaded into [subagents](/en/sub-agents#what-loads-at-startup); the exception is a [fork](/en/sub-agents#fork-the-current-conversation), which inherits the parent conversation and system prompt. A subagent's own auto memory, enabled with the subagent `memory` field, is a separate directory.
387
+
386
388
Claude reads and writes memory files during your session. When you see "Writing memory" or "Recalled memory" in the Claude Code interface, Claude is actively updating or reading from `~/.claude/projects/<project>/memory/`.
Copy file name to clipboardExpand all lines: content/en/docs/claude-code/output-styles.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,6 +101,8 @@ Output styles directly modify Claude Code's system prompt.
101
101
* All output styles trigger reminders for Claude to adhere to the output style instructions during the conversation.
102
102
* Custom output styles leave out Claude Code's built-in software engineering instructions, such as how to scope changes, write comments, and verify work, unless `keep-coding-instructions` is set to `true`.
103
103
104
+
Output styles apply to the main conversation only: a [subagent runs its own system prompt](/en/sub-agents#what-loads-at-startup), so styles don't change how subagents respond. A [fork](/en/sub-agents#fork-the-current-conversation) is the exception, because it inherits the parent's full system prompt.
105
+
104
106
Token usage depends on the style. Adding instructions to the system prompt increases input tokens, though prompt caching reduces this cost after the first request in a session. The built-in Explanatory and Learning styles produce longer responses than Default by design, which increases output tokens. For custom styles, output token usage depends on what your instructions tell Claude to produce.
Copy file name to clipboardExpand all lines: content/en/docs/claude-code/sub-agents.md
+9-1Lines changed: 9 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -327,6 +327,8 @@ Subagents inherit the [internal tools](/en/tools-reference) and MCP tools availa
327
327
*`ScheduleWakeup`
328
328
*`WaitForMcpServers`
329
329
330
+
The `Agent` tool itself is inherited, so a subagent can [spawn nested subagents](#spawn-nested-subagents).
331
+
330
332
To restrict tools, use the `tools` field as an allowlist or the `disallowedTools` field as a denylist. This example uses `tools` to allow only Read, Grep, Glob, and Bash. The subagent can't edit files, write files, or use any MCP tools:
331
333
332
334
```yaml theme={null}
@@ -855,7 +857,7 @@ A non-fork subagent's initial context contains:
855
857
856
858
* **System prompt**: the agent's own prompt plus environment details that Claude Code appends, not the full Claude Code system prompt. Custom subagents define theirs in the [markdown body](#write-subagent-files) or `prompt` field. Built-in agents have predefined prompts.
857
859
* **Task message**: the delegation prompt Claude writes when it hands off the work.
858
-
* **CLAUDE.md and memory**: every level of the [memory hierarchy](/en/memory#how-claude-md-files-load) the main conversation loads, including `~/.claude/CLAUDE.md`, project rules, `CLAUDE.local.md`, and managed policy files. The built-in Explore and Plan agents skip this.
860
+
* **CLAUDE.md files**: every level of the [CLAUDE.md hierarchy](/en/memory#how-claude-md-files-load) the main conversation loads, including `~/.claude/CLAUDE.md`, project rules, `CLAUDE.local.md`, and managed policy files. The built-in Explore and Plan agents skip this.
859
861
* **Git status**: a snapshot taken at the start of the parent session. Absent when the working directory isn't a Git repository or when [`includeGitInstructions`](/en/settings#available-settings) is `false`. Explore and Plan skip it regardless.
860
862
* **Preloaded skills**: full content of any skill named in the agent's [`skills` field](#preload-skills-into-subagents). Built-in agents don't preload skills.
861
863
* **Sibling roster**: a system reminder listing `main` and every other named agent in the session, each a valid `to` value for [`SendMessage`](#resume-subagents). {/* min-version: 2.1.206 */}Requires Claude Code v2.1.206 or later. The roster appears only when the subagent's tools include `SendMessage` and at least one other agent has a name, whether Claude named it when spawning it or it runs as an [agent team](/en/agent-teams) teammate. It is a snapshot taken when the subagent starts, so agents named later don't appear.
@@ -864,6 +866,12 @@ Explore and Plan are the only subagents that omit CLAUDE.md and git status. Ther
864
866
865
867
The main conversation reads Explore and Plan results with full CLAUDE.md context, so most rules don't need to reach the subagent itself. If a rule must, such as "ignore the `vendor/` directory," restate it in the prompt you give Claude when delegating.
866
868
869
+
Some main-conversation state never reaches a non-fork subagent:
870
+
871
+
* **Output style**: a subagent runs its own system prompt, so your [output style](/en/output-styles) doesn't shape its responses, except in a [fork](#fork-the-current-conversation).
872
+
* **Auto memory**: the main conversation's [auto memory](/en/memory#auto-memory) isn't loaded. To give a subagent persistent memory of its own, use the [`memory` field](#enable-persistent-memory).
873
+
* **Context window size**: a subagent's context window is sized by its own model, not the parent's. Delegating to a model with a smaller window gives that subagent the smaller window.
874
+
867
875
#### Resume subagents
868
876
869
877
Each subagent invocation creates a new instance with fresh context. To continue an existing subagent's work instead of starting over, ask Claude to resume it.
Copy file name to clipboardExpand all lines: content/github/anthropic-sdk-typescript/packages/google-cloud-sdk/CHANGELOG.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,13 @@
1
1
# Changelog
2
2
3
+
## 0.0.5 (2026-07-17)
4
+
5
+
Full Changelog: [google-cloud-sdk-v0.0.4...google-cloud-sdk-v0.0.5](https://github.com/anthropics/anthropic-sdk-typescript/compare/google-cloud-sdk-v0.0.4...google-cloud-sdk-v0.0.5)
6
+
7
+
### Chores
8
+
9
+
***internal:** version bump
10
+
3
11
## 0.0.4 (2026-07-16)
4
12
5
13
Full Changelog: [google-cloud-sdk-v0.0.3...google-cloud-sdk-v0.0.4](https://github.com/anthropics/anthropic-sdk-typescript/compare/google-cloud-sdk-v0.0.3...google-cloud-sdk-v0.0.4)
0 commit comments