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
Unique identifier for the agent. Auto-generated UUID if not set.
Human-readable name used in logs and traces.
Execution
Maximum number of model-call-then-tool-execution loops before stopping. Prevents infinite loops when the model keeps calling tools.
Token limit per run. Stops execution if exceeded.
Timeout in seconds for streaming responses.
Reliability
Automatically retry on transient network errors.
Maximum number of retry attempts for transient errors.
Validate tool arguments against their schema before execution.
State & Dependencies
Default session state available to tools. Merged with per-run state.
Dependencies injected into tools that declare them (e.g., database connections, API clients).
Tracing
Knowledge
RAG configuration for automatic knowledge retrieval. See Agent Integration.
Compression
Tool result compression to reduce token usage on long tool outputs.
Readers
File reader configuration for processing attached files. See File Readers.
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 Config
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:Enable or disable file reading.
Custom reader instance. When
None, a default BaseReader with all available built-in parsers is created.Maximum total character length of all extracted file content. When
None, no limit is applied.Format for injecting file content into the prompt.
"xml" wraps content in XML tags, "markdown" uses code blocks.