Agents
Agents
The following section shows you how to build agents with the AI SDK - systems where large language models (LLMs) use tools in a loop to accomplish tasks.
Overview
Learn what agents are, how they manage state, and why to use the ToolLoopAgent.
Building Agents
Create ToolLoopAgent instances with tools, runtime context, and loop control.
Workflow Patterns
Structured patterns using core functions for complex workflows.
Loop Control
Advanced execution control with stopWhen and prepareStep.
Configuring Call Options
Pass type-safe runtime inputs to dynamically configure agent behavior.
Tool Approvals
Review, approve, or deny sensitive tool calls before they execute.
Policy-Based Tool Approvals
Author tool authorization rules as code with @ai-sdk/policy-opa and Open Policy Agent.
Subagents
Delegate context-heavy tasks to specialized subagents while keeping the main agent focused.
WorkflowAgent
Build durable, resumable agents with @ai-sdk/workflow for the Workflow SDK.
Terminal UI
Run ToolLoopAgent instances in an interactive terminal interface.