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:For a full step-by-step guide, check the quickstart section or see practical examples in the examples section.
Model Providers
You can specify any model using the “provider/model” format. See all supported models in Model Capabilities. Some models require specific parameters (likemax_tokens for Claude). Use model_params to pass any additional model configuration:
.env file.
Running Agents
Execute agents by calling them with aprompt parameter and using .collect() to get the result:
Input and Output
Agents communicate throughMessage objects - Timbal’s data structure that standardizes both input and output.
Message objects:
.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
- ToolCallContent - 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():