> ## Documentation Index
> Fetch the complete documentation index at: https://psychiatrist.sudo.la/llms.txt
> Use this file to discover all available pages before exploring further.

# Structured output

> End a turn with a report typed by a zod schema.

Give a turn a zod object schema as `output`. The agent gets two tools for that turn, `done` (its parameters are the report; Claude Code checks them against the schema, and a report that does not match is sent back) and `error` (it cannot finish, and why), and a line added to the message asks it to end the turn with one of them (`askForReport: false` sends the message as it is, for prompts that say how the turn ends themselves). The result's `output` is typed by the schema.

```ts theme={null}
const review = await session.send("Review the change.", { output: z.object({ approve: z.boolean(), notes: z.string() }) });
if (review.output?.ok) console.log(review.output.report.approve);
else console.log("could not finish:", review.output?.error);
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.