Agent structured output
Skill kjuhwa/skills-hub/skills/agents/agent-structured-output
Configure an agent to return a Pydantic model as its final output instead of plain text.From its SKILL.md
npx -y skills add kjuhwa/skills-hub --skill agent-structured-outputAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
1.8 KB, 281 tokens by cl100k_base, as published. Nobody here has run it
agent-structured-output
Set output_type on an Agent to a Pydantic BaseModel. The SDK enforces structured output and returns a typed instance via result.final_output_as(MyModel).
When to apply
When downstream code must parse the agent's reply (routing, classification, evaluation pipelines). Replaces fragile string parsing with typed data.
Core snippet
from pydantic import BaseModel
from agents import Agent, Runner
class OutlineCheckerOutput(BaseModel):
good_quality: bool
is_scifi: bool
outline_checker_agent = Agent(
name="outline_checker_agent",
instructions="Read the given story outline, and judge the quality. Also, determine if it is a scifi story.",
output_type=OutlineCheckerOutput,
)
async def main():
result = await Runner.run(outline_checker_agent, "A space opera about clones...")
output = result.final_output_as(OutlineCheckerOutput)
print(output.good_quality, output.is_scifi)
Key notes
result.final_outputis the raw Pydantic model instance whenoutput_typeis set- Use
result.final_output_as(MyModel)for type-checked access - The agent runs until it produces output matching the schema (strict JSON schema by default)
- Works with nested models and optional fields
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.