Skip to main content

Agent Configuration

This page provides detailed documentation for all agent configuration parameters, including execution controls, context management, and output formatting options.

Core Parameters

Execution Control Parameters

max_iter

  • Type: int
  • Default: 15
  • Description: Maximum number of iterations an agent will attempt to complete a task
  • Range: 1-100 (recommended: 10-25)
The max_iter parameter controls how many times an agent can iterate through its execution loop when working on a task. This prevents infinite loops and ensures tasks complete within reasonable bounds.
Best Practices:
  • Set lower values (5-10) for simple tasks
  • Use higher values (20-30) for complex research or analysis tasks
  • Monitor iteration count to optimize performance

max_retry_limit

  • Type: int
  • Default: 2
  • Description: Maximum number of times to retry a failed operation
  • Range: 0-10 (recommended: 2-5)
Controls how many times an agent will retry operations that fail due to transient errors like network issues or API rate limits.
Use Cases:
  • API calls that may face rate limits
  • Network operations that may timeout
  • Tool executions that may fail intermittently

max_budget

  • Type: float | None
  • Default: None
  • Description: Hard USD cap on the agent run. Set via execution=ExecutionConfig(max_budget=...). Budget enforcement runs after each LLM call returns — in stop mode BudgetExceededError is raised, in warn mode a warning is logged and the agent continues.
Set a dollar limit via ExecutionConfig:
Benefits:
  • Prevents runaway costs in production — the guard fires before each LLM call in stop mode (default), so the over-budget call is never dispatched
  • Clean error handling in CLI mode
  • Zero overhead when not set
Mode behaviour: stop (default) enforces a pre-call hard ceiling; warn and callable modes check post-call and always let the call run. Pass on_budget_exceeded via ExecutionConfig to change the mode.

Context Management

context_length

  • Type: int
  • Default: None (uses model default)
  • Description: Maximum context window size in tokens
  • Common Values:
    • GPT-4: 128000
    • GPT-3.5: 16385
    • Claude 3: 200000
Defines the maximum amount of context (in tokens) that can be included in a single LLM request.
Important Considerations:
  • Larger context windows allow more information but increase costs
  • Some models perform better with focused context
  • Always validate against your LLM’s maximum context size

Output Formatting

markdown

  • Type: bool
  • Default: True
  • Description: Enable markdown formatting in agent outputs
Controls whether the agent formats its responses using markdown syntax for better readability.
Features When Enabled:
  • Headers using #, ##, etc.
  • Bold text with **text**
  • Code blocks with ```
  • Lists and tables
  • Links and images

Advanced Execution Controls

Performance Optimization

Error Handling Configuration

Configuration Patterns

Research Agent Configuration

Quick Task Agent Configuration

Environment Variable Overrides

Agent parameters can be overridden using environment variables:

Validation and Constraints

Parameter Validation Rules

Interaction Between Parameters

  1. Context Length and Max Iterations
    • Higher max_iter may require larger context_length
    • Each iteration adds to context usage
  2. Retry Limit and Execution Time
    • Higher max_retry_limit extends total execution time
    • Consider both when setting timeouts
  3. Markdown and Response Templates
    • “ enables template formatting
    • Templates should use markdown syntax when enabled

Troubleshooting

Common Issues

  1. Task taking too long
  2. Context window exceeded
  3. Need better quality responses

See Also