Cortex · OutputStructured output (
Structured output (data)
An agent with output.schema returns structured output in data, parsed against that schema, and response becomes optional. In the example, a member’s message is returned as an order. The model’s one turn is scripted; no model is called.
const Order = z.object({ night: z.string(), seats: z.number().int() });
const clerk = defineAgent({
id: 'clerk',
instructions: 'Read what the member wants into an order.',
output: { schema: Order },
});
const result = await clerk.run('Two seats for Sunday, please.', { llm }).result;1 writes {"data":{"night":"2026-10-25","seats":2}}{
ok: true,
output: { data: { night: '2026-10-25', seats: 2 } },
}Runs in this page on the installed package. The input and the expected output are defined by the example.