Skip to report

Agents SDK tools accept Zod 4 schemas

Follow the OpenAI Agents SDK’s Zod compatibility layer, which reads Zod 3 and Zod 4 schema internals and builds strict tool JSON Schema locally when conversion falls short.

openai/openai-agents-js #609 · PR by seratch · Merged

openai/openai-agents-js 8c0f8333..9bcb19a9

base and head as given

  • Agent tools now accept schemas from Zod 3 and Zod 4.
  • A JSON Schema compatibility layer was added to agent core.
  • Dedicated Node integration coverage was added for Zod 3 and Zod 4.
files changed
31
in a component
12
lines in components
784
components
6
public routes changed
0
schema statements
0
new dependencies
0
excluded by role
19
Based on 12 of 12 eligible changed files

Zod schema compatibility

Added
Before
Strict tool schema fallback did not exist
After
Unsupported schemas use a fallback

Tool authors can use Zod 3 or Zod 4 object schemas for strict tools. If upstream conversion omits required object metadata, supported shapes are converted locally; unsupported shapes raise a user error.

In favour

  • In favour: Returns a user error rather than emitting an incomplete schema

Against

  • Against: Depends on undocumented Zod internals across both supported major versions
Files changed in 6 components. Dependencies shown: 1 new, 5 unchanged
unchanged · 5new · 12 components added

1 new dependency between components — Type Definitions → Utility Functions

What else could behave differently

6 components · 44 files

These components import changed code, directly or through other files. A traced dependency is a place to review, not a confirmed runtime failure. Some paths stopped at heavily imported files; inspect those consumers separately.

Reached 3

ComponentSymbolCited atFilesReached by
Agents Core Sourcepackages/agents-core/src/Signature changed 1 of 16 changed symbols reaching itpackages/agents-core/src/agent.ts:121-1252115 direct · 3 at two steps · 2 at three steps · 1 at four steps
Trace path

Shortest component path from the changed symbol:

  1. Agents Core Source

Later steps follow file imports; they do not prove this symbol is called.

Type Definitionspackages/agents-core/src/types/Signature changed 1 of 15 changed symbols reaching itpackages/agents-core/src/agent.ts:121-12531 direct · 2 at two steps
Trace path

Shortest component path from the changed symbol:

  1. Agents Core Source
  2. Type Definitions

Later steps follow file imports; they do not prove this symbol is called.

Utility Functionspackages/agents-core/src/utils/Signature changed 1 of 15 changed symbols reaching itpackages/agents-core/src/agent.ts:121-12565 direct · 1 at two steps
Trace path

Shortest component path from the changed symbol:

  1. Agents Core Source
  2. Utility Functions

Later steps follow file imports; they do not prove this symbol is called.

Ranked lower 3

ComponentFilesReached by
packages/agents-core/src/shims/6none direct · 2 at two steps · 3 at three steps · 1 at four steps
packages/agents-core/src/tracing/6none direct · 2 at two steps · 2 at three steps · 2 at four steps
packages/agents-core/src/extensions/2none direct · 1 at two steps · 1 at three steps

Not traced past a hub 2

SymbolHub fileImported by
packages/agents-core/src/utils/tools.ts:getSchemaAndParserFromInputTypepackages/agents-core/src/agent.ts35
packages/agents-core/src/utils/tools.ts:convertAgentOutputTypeToSerializablepackages/agents-core/src/agent.ts35

Statements 3

AgentOutputType's signature changed and reached 21 files in the agents core source. 15321
packages/agents-core/src/agent.ts:121-125
AgentOutputType's signature changed and reached 3 files in type definitions. 12
packages/agents-core/src/agent.ts:121-125
AgentOutputType's signature changed and reached 6 files in utility functions. 51
packages/agents-core/src/agent.ts:121-125

36 reached files belong to no component — tests, docs and config.

Routes, schema, dependencies

No public URL, no migration and no new package.

Not stated

  • 5 routes were found on files whose role excludes them, so no route is claimed for them.

Inspect components, files and symbols

Component

Agents Core SourceModified
packages/agents-core/src/

2 files · 117 lines

5 dependents

Type DefinitionsModified
packages/agents-core/src/types/

1 file · 25 lines

5 dependents

Node Zod3 TestsAdded
integration-tests/node-zod3/

2 files · 70 lines

Node Zod4 TestsAdded
integration-tests/node-zod4/

2 files · 70 lines

Node TestsModified
integration-tests/node/

1 file · 1 line

Utility FunctionsModified
packages/agents-core/src/utils/

4 files · 501 lines

2 dependents

Utility exports added ZodInfer, ZodObjectLike, ZodTypeLike, asZodType, hasJsonSchemaObjectShape, readZodDefinition, readZodType, and zodJsonSchemaCompat.

File

Agents Core Sourcepackages/agents-core/src/
packages/agents-core/src/agent.ts

+59 −48

Agents Core Sourcepackages/agents-core/src/
packages/agents-core/src/tool.ts

+5 −5

Type Definitionspackages/agents-core/src/types/
packages/agents-core/src/types/helpers.ts

+13 −12

Node Zod3 Testsintegration-tests/node-zod3/
integration-tests/node-zod3/index.cjs

+37 −0

Node Zod3 Testsintegration-tests/node-zod3/
integration-tests/node-zod3/index.mjs

+33 −0

Node Zod4 Testsintegration-tests/node-zod4/
integration-tests/node-zod4/index.cjs

+37 −0

Node Zod4 Testsintegration-tests/node-zod4/
integration-tests/node-zod4/index.mjs

+33 −0

Node Testsintegration-tests/node/
integration-tests/node/index.cjs

+0 −1

Utility Functionspackages/agents-core/src/utils/
packages/agents-core/src/utils/zodJsonSchemaCompat.ts

+384 −0

Utility Functionspackages/agents-core/src/utils/
packages/agents-core/src/utils/zodCompat.ts

+54 −0

Utility Functionspackages/agents-core/src/utils/
packages/agents-core/src/utils/tools.ts

+35 −6

Utility Functionspackages/agents-core/src/utils/
packages/agents-core/src/utils/typeGuards.ts

+10 −12

Function

imports what changeddownstream of it, one mark per step

Diff

Agents Core Sourcepackages/agents-core/src/
packages/agents-core/src/agent.ts

1–1, 39–39, 42–47 and 6 more spans

Agents Core Sourcepackages/agents-core/src/
packages/agents-core/src/tool.ts

3–3, 22–22, 390–390 and 2 more spans

Type Definitionspackages/agents-core/src/types/
packages/agents-core/src/types/helpers.ts

1–1, 6–6, 20–24 and 2 more spans

Node Zod3 Testsintegration-tests/node-zod3/
integration-tests/node-zod3/index.cjs

1–37

Node Zod3 Testsintegration-tests/node-zod3/
integration-tests/node-zod3/index.mjs

1–33

Node Zod4 Testsintegration-tests/node-zod4/
integration-tests/node-zod4/index.cjs

1–37

Node Zod4 Testsintegration-tests/node-zod4/
integration-tests/node-zod4/index.mjs

1–33

Node Testsintegration-tests/node/
integration-tests/node/index.cjs

10–10

Utility Functionspackages/agents-core/src/utils/
packages/agents-core/src/utils/zodJsonSchemaCompat.ts

1–384

Utility Functionspackages/agents-core/src/utils/
packages/agents-core/src/utils/zodCompat.ts

1–54

Utility Functionspackages/agents-core/src/utils/
packages/agents-core/src/utils/tools.ts

7–12, 18–26, 68–68 and 3 more spans

Utility Functionspackages/agents-core/src/utils/
packages/agents-core/src/utils/typeGuards.ts

1–2, 10–14, 16–17 and 2 more spans

Analysis scope

690 → 6
  1. 690
    files at head
  2. 27
    components
  3. 6
    changed by this change

Where the new files landed

6 new files
New fileBelongs toUsed byCallsServes
integration-tests/node-zod3/2 new files
Node Zod3 Testsnew territory
nothing in the existing applicationnothing outside its own component
integration-tests/node-zod4/2 new files
Node Zod4 Testsnew territory
nothing in the existing applicationnothing outside its own component
packages/agents-core/src/utils/2 new files
Utility Functionsbase frame
Agents Core SourceType Definitions
Type Definitions

8 added files carry no component — 4 config, 3 test, 1 docs.

6components changed
3reached, not changed
2components added/removed
1dependencies added between components
0dependencies removed between components
0files moved to another path

31 files changed, 15 claims stated. 6 components reached in total.

naming: “model

narrative: “model

analyzer 0.2.0, config v1.9.0-phase8

Every line above is derived from 8c0f8333..9bcb19a9 and nothing else.