-
Notifications
You must be signed in to change notification settings - Fork 164
Open
Labels
bugSomething isn't workingSomething isn't workingdependenciesPull requests that update a dependency filePull requests that update a dependency filepackage:agents-coreskip-stale
Description
Describe the bug
When providing a properly-typed Zod schema as the property to an instance, TypeScript raises an error, even though the types appear compatible.
This prevents using custom Zod object schemas as the agent's output shape. outputType``Agent
Debug information
- Agents SDK version:
v0.0.10
- Runtime environment:
Node.js 22.16.0
- Package manager:
yarn
- TypeScript version:
5.8.3
- Zod version:
3.25.40
- IDE: WebStorm
Repro steps
- Install dependencies:
yarn add @openai/agents zod
- Create a file
my-test.ts
with the following minimal code:
import { Agent } from '@openai/agents';
import { z } from 'zod';
const SimpleOutput = z.object({
hotelName: z.string(),
hotelWeb: z.string(),
});
// This line causes a TypeScript error:
const agent = new Agent({
name: 'test agent',
instructions: 'Test instructions',
outputType: SimpleOutput, // Error is reported here!
});
- Observe the TypeScript error:
TS2322: Type 'ZodObject<{ hotelName: ZodString; hotelWeb: ZodString; }, ...>' is not assignable to type 'AgentOutputType<unknown> | undefined'.
...
Types have separate declarations of a private property '_cached'.
Expected behavior
The above use of a custom Zod schema should be accepted as a valid for the constructor.
It should be possible to specify any compatible Zod object to shape the output type, without TypeScript errors. outputType``Agent
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingdependenciesPull requests that update a dependency filePull requests that update a dependency filepackage:agents-coreskip-stale