

Structured Agent Output: Output.choice
Demonstrate structured agent outputs using ToolLoopAgent with Output.choice. Constrain agent outputs to predefined choices for predictable, type-safe responses.


Structured Agent Output: Output.array
Demonstrate structured agent outputs using ToolLoopAgent with Output.array. Returns structured array output with element schema for predictable, type-safe responses.


Loop Control: stopWhen
Demonstrate ToolLoopAgent loop control with stopWhen. Covers stepCountIs, hasToolCall, combined conditions, and a custom StopCondition with step timeline visualization.


PrepareStep: Trim Message History
Demonstrate ToolLoopAgent prepareStep for trimming long message history. Pre-seeded 24-message conversation shows context compression on the first run with per-step trim telemetry.
Explore More
Related Patterns


AI SDK Gemini Flash Text
Generate text and analyze market research using Google's Gemini 2.5 Flash. Includes interactive charts and data visualization.


Generate Text
Generate text from prompts using AI. Simple interface with character counting and response rendering.


OpenAI Structured Output
Generate structured output from AI prompts using OpenAI. Create typed data with generateText and Output.object().


Claude Structured Output
Generate structured output from AI prompts using Anthropic Claude. Create typed data with generateText and Output.object().
More in SDK API
generateText( )
Text and structured data generation with Output.object()
streamText( )
Streaming text and structured data with Output.object()
generateImage( )
Image generation examples
generateSpeech( )
Speech synthesis examples
transcribe( )
Audio transcription examples
tool( )
AI SDK tool API examples and patterns







