Ag2 Structured Output

Get a typed Python value back from an AG2 beta `Agent` instead of free text. Pass `response_schema=` (a Pydantic model, dataclass, primitive, union, `ResponseSchema`, or `@response_schema` validator) and read the parsed result via `await reply.content()`. Use when the user wants validated structured output, classification, extraction, or scoring. Covers `ResponseSchema`, `@response_schema`, `PromptedSchema` (for providers without native structured output), per-turn override, validation retries, and primitive embedding.

ag2ai Updated

File contents

ag2ai/build-with-ag2/tree/main/.agents/skills/ag2-structured-output commit f86be09685

Frequently asked questions

npx skillmds@latest add ag2ai/ag2-structured-output-2