Skip to content

AgentConfig

Configuration options for agent behavior.

Quick Example

from mamba_agents import Agent, AgentConfig, CompactionConfig

config = AgentConfig(
    system_prompt="You are a helpful assistant.",
    max_iterations=15,
    track_context=True,
    auto_compact=True,
    context=CompactionConfig(
        strategy="hybrid",
        trigger_threshold_tokens=50000,
    ),
)

agent = Agent("gpt-4o", config=config)

Configuration Options

Option Type Default Description
system_prompt str None System prompt for the agent
max_iterations int 10 Maximum tool-calling iterations
track_context bool True Enable message tracking
auto_compact bool True Auto-compact when threshold reached
graceful_tool_errors bool True Convert tool exceptions to ModelRetry
context CompactionConfig None Custom compaction settings
tokenizer TokenizerConfig None Custom tokenizer settings

API Reference

AgentConfig

Bases: BaseModel

Configuration for agent execution.

ATTRIBUTE DESCRIPTION
max_iterations

Maximum tool-calling iterations before stopping.

TYPE: int

system_prompt

System prompt for the agent. Can be a string or TemplateConfig.

TYPE: str | TemplateConfig

context

Context compaction configuration. None uses settings default.

TYPE: CompactionConfig | None

tokenizer

Tokenizer configuration. None uses settings default.

TYPE: TokenizerConfig | None

track_context

Whether to track messages internally across runs.

TYPE: bool

auto_compact

Whether to automatically compact when threshold is reached.

TYPE: bool