What are Agents?
Agents are autonomous execution units that orchestrate LLM interactions with tool calling. Without tools, an agent functions as a basic LLM. The simplest agent requires just a name and model:Reading guide
The sidebar follows a basics → platform → production path. You can jump anywhere, but this order matches how most agents are built:- Tools — give the agent capabilities (the core primitive)
- Structured output — constrain what comes back
- Memory → Memory compaction — multi-turn context, then keeping it within the window
- Skills — domain packages (knowledge + tools) once the agent loop makes sense
- Dynamic agents — runtime prompts and tool sets
- Background tasks · Commands — utilities (async tools, slash shortcuts)
suspend(), and durable resume (agents, workflow steps, and tools).
This page covers running agents, models, and I/O. The sections below are the reference for that; the linked pages go deeper on each topic.
Model Providers
You can specify any model using the “provider/model” format. See all supported models in the Model Reference. Some models require specific parameters (likemax_tokens for Claude). Pass it as a top-level field:
.env file.
Fallback Models
UseFallbackModel when you want an agent to try another model if the primary provider is rate limited, temporarily unavailable, times out, or returns a retryable server error.
FallbackExhausted with the per-model errors.
For per-model settings, use ModelEntry:
Thinking and reasoning
Some models support extended thinking before responding. Check per-model capabilities on the Model Reference pages. Configure at construction time viamodel_params (per-request overrides use provider_params — see Overriding Model Configuration below):
Running Agents
Execute agents by calling them with aprompt parameter and using .collect() to get the result:
Streaming Events
For real-time processing, you can stream events as they happen:Approval-Required Tools
Any runnable — Tool, Agent, or Workflow step — can pause for human approval before it runs. Mark it withrequires_approval, listen for ApprovalEvent, and resume by calling the runnable again with resume:
pending_approvals(), status reasons, usage counters, plus suspend() for asking the user mid-run — lives on the dedicated Human in the Loop section.
Input
Agents communicate throughMessage objects - Timbal’s data structure that standardizes both input and output.
Message objects:
user_id and role from the input parameters. Input parameters work with both .collect() and streaming.
For more information about accessing input parameters and using the run context, see the Context & State Management page.
Overriding Model Configuration
What if you want to change the model,max_tokens, or thinking config for each run? Instead of creating multiple agents, you can pass these as input parameters. This is useful for A/B testing different models, adjusting token limits per request, or dynamically selecting models based on task complexity.
Output
Calling.collect() returns an OutputEvent containing the agent’s response. Access the Message via the .output property:
Learn more about events in Events & Streaming.
Messages
Messages are the structured data format that agents use to communicate. They contain a role and content, with automatic handling of different content types and provider compatibility.- user - Messages from the user
- assistant - Messages from the AI agent
- system - System instructions and context
- tool - Tool execution results
- TextContent - Plain text messages
- FileContent - Files like PDFs, images, documents
- ToolUseContent - Function calls to tools
- ToolResultContent - Results from tool executions
Message.validate():
Files
Agents can process files directly through the message content system. The framework automatically handles file reading, content extraction, and formatting for the AI model.- Text files (.txt, .md) - Direct content inclusion
- PDFs (.pdf) - Text extraction with structure preservation
- Images (.png, .jpg, .gif) - Visual analysis through vision-capable models
- Spreadsheets (.xlsx, .csv) - Structured data representation
- Documents (.docx) - Text and formatting extraction
File objects using File.validate():