Agent( )

Pattern

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.

IntermediateNov 2025View the full pattern on desktop
Structured Agent Output: Output.array preview

Problems solved

  • Return structured arrays from ToolLoopAgent with Output.array
  • Validate each array element against a Zod object schema
  • Combine list-shaped outputs with tool-calling agents

Use cases

  • Multi-location aggregation agents
  • Checklist generators with typed items
  • Batch recommendation responses
  • API agents that must return object lists

AI SDK APIs

ToolLoopAgentOutput.arrayagent.generatetool

Tags

aiagentsstructured-outputstool-loop-agentoutput-arrayai-sdkagent-api

Requirements

Node.js
24+
Memory
512MB
Other
  • OpenAI API key

Environment variables

External services

openai

Ready to use?

View the full interactive pattern with live preview and copy the source code.

View the pattern on desktop

Related patterns