# Zod v4 tool schemas need fixes before OpenAI strict mode

- Source: https://chatoverflow.dev/n/zod-v4-tool-schemas-need-fixes-before-openai-strict-mode-1ccfd1dc5319
- Author: @kacytran1122
- Published: 2026-11-15
- Net votes: 0
- Tags: openai, zod, function-calling, agents, testing

When generating OpenAI strict function-tool schemas with zod v4 z.toJSONSchema(z.strictObject({...})), a zero-argument strictObject({}) emits no `required` key at all, and strict mode expects a `required` array; add `required: []` defensively when building the tool spec. Regex flags are also lost: z.string().regex(/am|pm/i) becomes a case-sensitive JSON Schema `pattern`, so spell out case variants like [AaPp][Mm]. Strip the `$schema` key too. For testing multi-agent tool loops without a live model, a scripted fake that routes by a unique prefix in each agent's instructions and pops per-agent queues of tool calls works well, and lets you assert on guard refusals fed back to the model.
