pub struct AgentConfig {
pub max_iterations: usize,
pub max_retries: u32,
pub retry_delay_ms: u64,
pub max_tool_result_size: usize,
pub max_todo_reminders: usize,
pub iteration_warning_threshold: usize,
pub compression: CompressionConfig,
pub max_tokens: u32,
pub context_size_override: Option<u32>,
pub think: bool,
pub verify_strategy: VerificationStrategy,
pub project_path: Option<PathBuf>,
}Expand description
Agent runtime configuration.
Controls iteration limits, retry behavior, size thresholds, and compression settings. All defaults match the original hardcoded values for backward compatibility.
Fields§
§max_iterations: usizeMaximum number of iterations in the main loop.
Default: 200
Why this value?
- Sufficient for most common tasks (file edits, code review, simple builds)
- Prevents infinite loops and runaway operations
- Balances task completion with resource efficiency
What happens when limit is reached?
- Agent stops execution gracefully
- User receives detailed warning message
- Can continue, break down task, or resume
Examples:
- Simple task (edit file): ~5-10 iterations
- Medium task (refactor module): ~15-30 iterations
- Complex task (build system): ~40-50 iterations (may hit limit)
max_retries: u32Maximum retry attempts for API calls.
Default: 5
Why this value?
- Handles transient network failures
- Balances resilience with response time
- Most failures resolve within 2-3 retries
retry_delay_ms: u64Delay between retry attempts (milliseconds).
Default: 1000ms
Why this value?
- Gives API server time to recover
- Not too long to frustrate users
- Often used with exponential backoff
max_tool_result_size: usizeMaximum size for tool execution results (bytes).
Default: 50,000 (50KB)
Why this value?
- Prevents oversized responses from breaking API calls
- Fits within typical context window limits
- Most tool results are <10KB
Truncation behavior:
- Results larger than this are truncated
- Truncation message added: “⚠️ Output truncated (X bytes total)”
- User can request specific portions if needed
max_todo_reminders: usizeMaximum number of todo reminders per todo item.
Default: 2
Why this value?
- Prevents infinite loops when model doesn’t update todo status
- Gives model multiple chances to notice pending work
- After limit, stops reminding (assumes model won’t update)
iteration_warning_threshold: usizeIteration count threshold for warning user.
Default: max_iterations - 10 (190)
Why this value?
- Warns user 10 iterations before limit
- Gives time to decide: continue, break down task, or cancel
- Prevents surprising cutoff at exactly max_iterations
compression: CompressionConfigContext compression configuration.
Controls when and how to compress long conversations.
See CompressionConfig for details.
max_tokens: u32Maximum tokens for API responses.
Default: 4096 (from QUICK_ACTION_MAX_TOKENS)
context_size_override: Option<u32>Override for context window size.
Default: None (use provider’s default)
think: boolEnable thinking mode for extended reasoning.
Default: false
verify_strategy: VerificationStrategyCode verification strategy for write operations.
Controls whether and when code quality checks run on edit/write/multi_edit.
None: No verificationPost: Verify after write (default)Pre: Verify before write, block if errorsPreQuick: Quick syntax check before, full check after
project_path: Option<PathBuf>Project root path for code verification.
Used to detect project type (Rust/Node.js/Python/Go) and run appropriate verification commands (cargo check, tsc, etc.).
Implementations§
Source§impl AgentConfig
impl AgentConfig
Sourcepub fn new(
max_tokens: u32,
context_size_override: Option<u32>,
think: bool,
compression: CompressionConfig,
) -> Self
pub fn new( max_tokens: u32, context_size_override: Option<u32>, think: bool, compression: CompressionConfig, ) -> Self
Create a new config with all settings.
Sourcepub fn with_verify_strategy(
verify_strategy: VerificationStrategy,
project_path: Option<PathBuf>,
) -> Self
pub fn with_verify_strategy( verify_strategy: VerificationStrategy, project_path: Option<PathBuf>, ) -> Self
Create a new config with verification strategy.
Sourcepub fn with_max_iterations(max_iterations: usize) -> Self
pub fn with_max_iterations(max_iterations: usize) -> Self
Create a new config with custom max_iterations.
Automatically adjusts iteration_warning_threshold to max_iterations - 10.
Sourcepub fn with_compression(compression: CompressionConfig) -> Self
pub fn with_compression(compression: CompressionConfig) -> Self
Create a new config with custom compression settings.
Sourcepub fn simple_task() -> Self
pub fn simple_task() -> Self
Create a config optimized for simple tasks.
Use for: file edits, quick queries, simple tool calls. Characteristics: lower iteration limit, smaller result size.
Sourcepub fn complex_task() -> Self
pub fn complex_task() -> Self
Create a config optimized for complex tasks.
Use for: refactoring, build systems, multi-file changes. Characteristics: higher iteration limit, larger result size.
Sourcepub fn max_tokens(&self) -> u32
pub fn max_tokens(&self) -> u32
Get max tokens for API responses.
Sourcepub fn context_size_override(&self) -> Option<u32>
pub fn context_size_override(&self) -> Option<u32>
Get context size override.
Sourcepub fn compression_config(&self) -> &CompressionConfig
pub fn compression_config(&self) -> &CompressionConfig
Get compression config.
Sourcepub fn compression_config_mut(&mut self) -> &mut CompressionConfig
pub fn compression_config_mut(&mut self) -> &mut CompressionConfig
Get mutable compression config.
Sourcepub fn verify_strategy(&self) -> VerificationStrategy
pub fn verify_strategy(&self) -> VerificationStrategy
Get verification strategy.
Sourcepub fn project_path(&self) -> Option<&Path>
pub fn project_path(&self) -> Option<&Path>
Get project path for verification.
Trait Implementations§
Source§impl Clone for AgentConfig
impl Clone for AgentConfig
Source§fn clone(&self) -> AgentConfig
fn clone(&self) -> AgentConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more