The schema gate runs a ZodDocumentation Index
Fetch the complete documentation index at: https://docs.pecta.ai/llms.txt
Use this file to discover all available pages before exploring further.
safeParse against ctx.output (or ctx.input when you set target: "input") and fails the evaluation if validation does not succeed. It is the right tool when your agent is expected to return structured data — a JSON object, a typed array, a specific string format — and you need a hard guarantee that every field is present and correctly typed before the output reaches downstream code.
On failure, the gate returns up to five Zod validation issues in details so you can diagnose exactly which fields are wrong without needing to re-run the agent.
Usage
What a failure looks like
When validation fails,reason contains a human-readable summary and details contains the raw Zod issues (capped at five):
details.total reflects the true number of Zod issues even when more than five exist.
Configuration
Any Zod schema —
z.object, z.array, z.string, z.union, or any composition thereof. Pass it as the first argument to gates.schema(...).Which field of the evaluation context to validate. Defaults to
"output". Set to "input" to validate what the agent received rather than what it produced.Override the gate name recorded in results. Defaults to
"schema".