> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Execution

> Control how agents run - iterations, timeouts, and limits

Configure execution limits to prevent runaway agents and control costs.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    subgraph "Execution Control"
        A[🤖 Agent] --> L[⏱️ Limits]
        L --> I[🔄 Max Iterations]
        L --> T[⏰ Timeout]
    end
    
    classDef agent fill:#6366F1,stroke:#7C90A0,color:#fff
    classDef limit fill:#F59E0B,stroke:#7C90A0,color:#fff
    
    class A agent
    class L,I,T limit
```

## Quick Start

<Steps>
  <Step title="Default Execution">
    ```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    use praisonai::Agent;

    // Uses safe defaults: 10 max iterations
    let agent = Agent::new()
        .name("Assistant")
        .instructions("You are a helpful assistant")
        .build()?;

    let response = agent.chat("Hello!").await?;
    ```
  </Step>

  <Step title="Custom Iteration Limits">
    ```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    use praisonai::Agent;

    // Limit tool loops to prevent runaway agents
    let agent = Agent::new()
        .name("Assistant")
        .max_iterations(5)  // Max 5 tool call loops
        .build()?;

    let response = agent.chat("Research this topic").await?;
    ```
  </Step>

  <Step title="High-Volume Agent">
    ```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    use praisonai::Agent;

    // Allow more iterations for complex tasks
    let agent = Agent::new()
        .name("Researcher")
        .max_iterations(20)  // Allow more tool calls
        .verbose(true)       // Monitor progress
        .build()?;
    ```
  </Step>
</Steps>

***

## Configuration

| AgentBuilder Method  | Type    | Default | Description             |
| -------------------- | ------- | ------- | ----------------------- |
| `.max_iterations(n)` | `usize` | `10`    | Maximum tool call loops |
| `.verbose(bool)`     | `bool`  | `false` | Enable verbose output   |
| `.stream(bool)`      | `bool`  | `true`  | Enable streaming        |

***

## Best Practices

<AccordionGroup>
  <Accordion title="Set reasonable iteration limits">
    5-10 iterations handles most tasks. Higher values risk infinite loops.
  </Accordion>

  <Accordion title="Use timeouts for safety">
    Always set timeouts to prevent stuck agents from running indefinitely.
  </Accordion>
</AccordionGroup>

***

## Related

<CardGroup cols={2}>
  <Card title="Agent" icon="robot" href="/docs/rust/agent">
    Agent configuration
  </Card>

  <Card title="Autonomy" icon="robot" href="/docs/rust/autonomy">
    Autonomy levels
  </Card>
</CardGroup>
