AgentConfig is an immutable dataclass that controls every aspect of agent behavior. Pass it when creating an agent, or use the defaults.
Basic Configuration
Configuration Reference
Identity
Execution
Maximum number of model-call-then-tool-execution loops before stopping. Prevents infinite loops when the model keeps calling tools.
Reliability
State & Dependencies
Dependencies injected into tools that declare them (e.g., database connections, API clients).
Tracing
Tracing configuration (backward compat). Prefer passing
tracing=Tracing(...) directly to Agent. See Tracing for details.Compression
Compression is configured directly on theAgent constructor (not in AgentConfig):
Readers
File reader configuration for processing attached files. See File Readers.
Memory
Memory is configured directly on theAgent constructor:
Knowledge
Knowledge (RAG) is configured directly on theAgent constructor:
Thinking
The thinking layer is configured directly on theAgent constructor (not in AgentConfig):
Immutable Updates
AgentConfig is frozen after creation. Use with_updates() to create a modified copy:
base_config is unchanged. This pattern makes it safe to share configs across agents.
Compression
Compress large tool results to save tokens:Compression uses a separate model call to summarize tool output. This adds a small amount of latency but can significantly reduce total token usage for tools that return large results.
Readers Config
Configure file reader behavior for processing attached files:Custom reader instance. When
None, a default BaseReader with all available built-in parsers is created.Format for injecting file content into the prompt.
"xml" wraps content in XML tags, "markdown" uses code blocks.Audio Transcription
The audio transcriber is configured directly on theAgent constructor. It automatically transcribes voice messages (from Telegram, Discord, or direct arun() calls) to text before the model sees them.
How It Works
Whenaudio_transcriber is set:
- Before the pipeline runs,
_transcribe_audio()iterates over messages withAudioattachments - Each audio clip is transcribed via the configured backend (Whisper by default)
- The transcript text is appended to the message’s
contentfield - The
audiofield is cleared from the message so non-audio models don’t receive rawinput_audioblocks
Security
Security features are configured directly on theAgent constructor:
Usage Tracking
Track token usage and estimated cost across agent runs:Deep Research
The deep research layer is configured directly on theAgent constructor:
DeepResearchConfig Reference
Research depth preset.
"quick" (1 wave, 8 sources), "standard" (3 waves, 15 sources), "deep" (5 waves, 30 sources).Backend-specific config (API keys, CSE ID, etc.). Required for Google CSE and SerpAPI.
When to run research:
"always" (every run), "auto" (model decides), "tool" (explicit tool call).