> ## 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.

# Tool Reliability

> How PraisonAI tools handle errors, retries, and edge cases

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    subgraph "Tool Reliability"
        Request[📋 User Request] --> Process[⚙️ Tool Reliability]
        Process --> Result[✅ Result]
    end

    classDef input fill:#6366F1,stroke:#7C90A0,color:#fff
    classDef process fill:#189AB4,stroke:#7C90A0,color:#fff
    classDef output fill:#10B981,stroke:#7C90A0,color:#fff

    class Request input
    class Process process
    class Result output
```

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent
    participant Feature as Tool Reliability

    User->>Agent: Request
    Agent->>Feature: Process request
    Feature-->>Agent: Result
    Agent-->>User: Response
```

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent, duckduckgo

agent = Agent(name="Researcher", tools=[duckduckgo])
agent.start("Find recent news about tool reliability in AI agents")
```

The user relies on search tools; PraisonAI retries and fallbacks keep the agent run stable when a provider fails.

PraisonAI tools are designed with **reliability-first** principles.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
flowchart LR
    A[Tool Call] --> B{Success?}
    B -->|Yes| C[Return Results]
    B -->|No| D{Retries Left?}
    D -->|Yes| E[Wait & Retry]
    E --> A
    D -->|No| F[Return Error]
    
    style A fill:#8B0000,color:#fff
    style C fill:#189AB4,color:#fff
    style F fill:#189AB4,color:#fff

    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff

```

## Search Provider Priority

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
flowchart TD
    A[search_web] --> B{Tavily Available?}
    B -->|Yes| C[Use Tavily]
    B -->|No| D{Exa Available?}
    D -->|Yes| E[Use Exa]
    D -->|No| F{You.com Available?}
    F -->|Yes| G[Use You.com]
    F -->|No| H{DuckDuckGo?}
    H -->|Yes| I[Use DuckDuckGo]
    H -->|No| J[Use SearxNG]
    
    style A fill:#8B0000,color:#fff
    style C fill:#189AB4,color:#fff
    style E fill:#189AB4,color:#fff
    style G fill:#189AB4,color:#fff
    style I fill:#189AB4,color:#fff
    style J fill:#189AB4,color:#fff
```

<CardGroup cols={2}>
  <Card title="Automatic Fallback" icon="rotate">
    `search_web` tries providers in order until one succeeds
  </Card>

  <Card title="Retry Logic" icon="repeat">
    Each provider retries **3 times** with exponential backoff
  </Card>
</CardGroup>

## Quick Start

<Steps>
  <Step title="Simple Usage">
    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        from praisonaiagents.tools import search_web
        
        # Automatically uses best available provider
        results = search_web("AI news 2024")
    ```
  </Step>

  <Step title="With Configuration">
    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        from praisonaiagents.tools import internet_search
        
        # Direct DuckDuckGo access with retry
        results = internet_search("Python tutorials", retries=3)
    ```
  </Step>
</Steps>

## Error Handling

<AccordionGroup>
  <Accordion title="Check for errors">
    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    results = search_web("query")
    if results and "error" in results[0]:
        print(f"Failed: {results[0]['error']}")
    ```
  </Accordion>

  <Accordion title="list_processes handles None">
    System processes may return `None` for CPU/memory. Defaults to `0.0`.
  </Accordion>
</AccordionGroup>

## API Keys

| Provider   | Environment Variable | Quality  |
| ---------- | -------------------- | -------- |
| Tavily     | `TAVILY_API_KEY`     | ⭐⭐⭐ Best |
| Exa        | `EXA_API_KEY`        | ⭐⭐⭐ Best |
| You.com    | `YDC_API_KEY`        | ⭐⭐ Good  |
| DuckDuckGo | None needed          | ⭐ Basic  |

<Tip>
  Set `TAVILY_API_KEY` for best search quality. DuckDuckGo is the free fallback.
</Tip>

## Auto-Approve Tools

```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
approve:
  - write_file
  - execute_command

agents:
  writer:
    tools:
      - write_file
```

<Warning>
  Only auto-approve tools you trust.
</Warning>

***

## Schema-level Reliability

Runtime reliability (error handling, retries, fallbacks) complements schema-time reliability for comprehensive tool safety.

**Schema validation** catches broken tools at development time:

* Invalid OpenAI function schemas
* Missing required fields like `properties`
* Non-JSON-serializable values
* Duplicate tool names in lists

**Runtime reliability** handles execution errors:

* Network failures and timeouts
* API rate limits and retries
* Provider fallbacks
* Process crashes

For schema validation details and fixing validation errors, see [Tool Schema Validation](/docs/features/tool-schema-validation).

## Related

<CardGroup cols={2}>
  <Card title="Custom Tools" icon="wrench" href="/docs/tools/custom">
    Build your own agent tools
  </Card>

  <Card title="Tools Overview" icon="toolbox" href="/docs/tools/tools">
    Browse PraisonAI tool documentation
  </Card>
</CardGroup>
