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

# Agents

> Orchestrate multiple tools and actions with AI agents that can make intelligent decisions

## Overview

Agents are AI-powered orchestrators that can intelligently decide which tools and actions to use based on user questions. Unlike actions that execute a single task, agents can chain multiple tool calls together, make decisions, and handle complex workflows autonomously.

<Frame>
  <img src="https://mintcdn.com/gurubase/L45gNxIKTPhmtYGQ/images/guides/agents/list.png?fit=max&auto=format&n=L45gNxIKTPhmtYGQ&q=85&s=bc976e1ad6b220d0c3332c55dd3e9411" alt="Agents" width="2900" height="1556" data-path="images/guides/agents/list.png" />
</Frame>

Agents transform your Guru into an intelligent assistant that can:

* orchestrate multiple tools and actions
* make autonomous decisions about which tools to use
* chain tool calls together for complex workflows
* handle nested agent calls (agents calling other agents)
* process structured or free-form responses

Each Guru has a limit on the number of agents (e.g., "9 of 10 agents used").

## How Agents Work

Agents use an intelligent orchestration system:

1. **When to Trigger This Agent**: The Guru checks if the user's question matches your defined conditions
2. **Tool Selection**: The agent selects from its available tools (actions or other agents) based on the task
3. **Execution**: The agent makes autonomous decisions about which tools to call and in what order
4. **Nested Execution**: Agents can call other agents, creating nested execution chains
5. **Response Handling**: The **Usage Instructions** guide the AI on how to interpret and present the agent's response

## Creating an Agent

The agent creation process consists of four main steps:

1. Basic Information
2. Tool Selection
3. Agent Configuration
4. Usage Instructions, Scheduling, and Testing

### Basic Information

<Frame>
  <img src="https://mintcdn.com/gurubase/L45gNxIKTPhmtYGQ/images/guides/agents/basic-info.png?fit=max&auto=format&n=L45gNxIKTPhmtYGQ&q=85&s=4c84a035f0d59b7da29cf9fa83538104" alt="Agent Basic Configuration" width="1330" height="896" data-path="images/guides/agents/basic-info.png" />
</Frame>

* **Agent Name**: Provide a descriptive name that appears in your agents list (e.g., "Address manager")
* **When to Trigger This Agent**: Be specific about keywords, patterns, or user intents to ensure it only runs when appropriate
  * Example: "When the user wants to do any operation regarding their address or wants to guess the secret"

### Agent Configuration

<Frame>
  <img src="https://mintcdn.com/gurubase/L45gNxIKTPhmtYGQ/images/guides/agents/config.png?fit=max&auto=format&n=L45gNxIKTPhmtYGQ&q=85&s=60cac15b90e1303cc4ccf1ffad795b69" alt="Agent Configuration" width="1302" height="1248" data-path="images/guides/agents/config.png" />
</Frame>

Configure how the agent behaves and processes requests:

* **System Prompt**: Required instructions that define the agent's behavior and capabilities
  * Example: "You are an assistant that manages addresses. You can either get or update addresses. You are also used for guessing the secret"

* **Output Schema (Optional)**: JSON schema for structured output. Leave empty for free-form responses
  * Example:
  ```json theme={null}
  {
    "message": "string",
    "reasoning": "string"
  }
  ```

* **Max Tool Calls**: Maximum number of tool calls per execution (1-100)
  * Limits how many tools the agent can call in a single execution
  * Default: 10

* **Max Depth**: Maximum nesting depth for agent calls (1-10)
  * Controls how deeply agents can call other agents
  * Default: 5
  * Prevents infinite recursion in nested agent scenarios

### Tool Selection

<Frame>
  <img src="https://mintcdn.com/gurubase/L45gNxIKTPhmtYGQ/images/guides/agents/selected-tools.png?fit=max&auto=format&n=L45gNxIKTPhmtYGQ&q=85&s=d4bbbf295a02d81fe86c3a3eb5cb2fc6" alt="Selected Tools" width="1312" height="430" data-path="images/guides/agents/selected-tools.png" />
</Frame>

Select which actions and agents this agent can use as tools. Available tools include:

* **Actions**: Python Code and API Call actions you've created
* **Other Agents**: Other agents in your Guru (enabling nested agent calls)

<Frame>
  <img src="https://mintcdn.com/gurubase/L45gNxIKTPhmtYGQ/images/guides/agents/tools-list.png?fit=max&auto=format&n=L45gNxIKTPhmtYGQ&q=85&s=b090b811c973dc7e941a6485673ccd63" alt="Available Tools" width="1308" height="1054" data-path="images/guides/agents/tools-list.png" />
</Frame>

* Use the search bar to filter available tools
* Selected tools appear as tags that can be removed individually
* Use "Clear all" to deselect all tools
* The agent will intelligently choose which tools to use based on the user's question

### Usage Instructions and Testing

<Frame>
  <img src="https://mintcdn.com/gurubase/L45gNxIKTPhmtYGQ/images/guides/agents/how-to-use-the-response.png?fit=max&auto=format&n=L45gNxIKTPhmtYGQ&q=85&s=c47455a3d3bc97d407cefd6813d7e0bc" alt="Usage Instructions Configuration" width="1324" height="916" data-path="images/guides/agents/how-to-use-the-response.png" />
</Frame>

* **Usage Instructions**: Provide instructions for how the AI should interpret and present the agent's response to users
  * Example: "Extract the message and reasoning from the JSON response and present them in a clear format"

**Testing:**

* Use the "Test Agent" button to verify your configuration
  * Tools will be mocked (not actually executed) during testing
  * Test results show the agent's decision-making process and tool selection

### Scheduling

<Frame>
  <img src="https://mintcdn.com/gurubase/L45gNxIKTPhmtYGQ/images/guides/agents/scheduling.png?fit=max&auto=format&n=L45gNxIKTPhmtYGQ&q=85&s=1af4f403a307d396fbd5539066f01656" alt="Schedule Configuration" width="1306" height="560" data-path="images/guides/agents/scheduling.png" />
</Frame>

**Scheduling Agents:**

* Enable scheduling using the toggle switch
* Configure the execution schedule using a cron expression in standard format: `minute hour day month weekday`
  * Example: `0 9 * * *` runs daily at 9 AM
  * Example: `*/5 * * * *` runs every 5 minutes
* Scheduled agents display their cron expression in the agents list

## Managing Agents

* View all configured agents with their name, number of tools, status (Enabled/Disabled), and schedule (cron expression if scheduled)

* Click the menu icon (⋮) next to any agent to:
  * **Edit**: Modify the agent's configuration
  * **Disable**: Temporarily disable without deleting
  * **Delete**: Permanently remove the agent

* Click "View Code" to see integration code samples for the agent

* Enable or disable agents at any time

* Disabled agents won't be triggered by user questions

* **Note**: If a tool (action or agent) used by an agent is deleted, that agent will be automatically disabled

## Agent History

<Frame>
  <img src="https://mintcdn.com/gurubase/L45gNxIKTPhmtYGQ/images/guides/agents/exec-list.png?fit=max&auto=format&n=L45gNxIKTPhmtYGQ&q=85&s=04541484a63f642ca9595d149d93e041" alt="Agent History" width="2900" height="2038" data-path="images/guides/agents/exec-list.png" />
</Frame>

View the execution history for all agents from the Agents page by clicking the "History" button. The history table displays:

* **Status**: Execution outcome (Completed or Failed)
* **Action Name**: Name of the executed agent
* **Type**: Always "Agent" for agent executions
* **Source**: How the agent was triggered (Api, Scheduled, Test, etc.)
* **Started At**: Date and time when execution began
* **Duration**: Execution time in seconds
* **Test**: Whether the execution was a test run

<Frame>
  <img src="https://mintcdn.com/gurubase/L45gNxIKTPhmtYGQ/images/guides/agents/nested-display.png?fit=max&auto=format&n=L45gNxIKTPhmtYGQ&q=85&s=96cef1c150f43a2257d044269723f36e" alt="Nested Tool Calls" width="2318" height="518" data-path="images/guides/agents/nested-display.png" />
</Frame>

**Nested Execution View:**
The execution details page shows a hierarchical view of nested tool calls:

* Top-level agent execution
* Indented tool calls showing which tools were called
* Further indentation for nested agent calls
* Each level shows its own status, duration, and type

This table helps you understand the agent's decision-making process, debug failed executions, and optimize tool selection.

Click the eye icon on any row to view detailed execution information.

<Frame>
  <img src="https://mintcdn.com/gurubase/L45gNxIKTPhmtYGQ/images/guides/agents/exec-details.png?fit=max&auto=format&n=L45gNxIKTPhmtYGQ&q=85&s=11c4e629f10f2b2fdcb2352207af3a2f" alt="Agent Execution Details" width="2884" height="2056" data-path="images/guides/agents/exec-details.png" />
</Frame>

**Execution Details Page:**

* **Execution Info**: Unique execution ID, status, depth, agent name, source, and test flag
* **Timing**: Start time, duration, and completion time
* **Input Data**: Parameters and values used during execution (collapsible)
* **Output Data**: Agent's response data (collapsible)
* **Tool Calls**: List of all tool calls made during execution (collapsible)
* **Nested Executions**: Immediate childrens of the agent (collapsible)

## Integration

<Frame>
  <img src="https://mintcdn.com/gurubase/L45gNxIKTPhmtYGQ/images/guides/agents/openai-sdk.png?fit=max&auto=format&n=L45gNxIKTPhmtYGQ&q=85&s=81ad32781ccd062c8ddc5bdf6c1025f7" alt="OpenAI SDK Integration" width="1386" height="916" data-path="images/guides/agents/openai-sdk.png" />
</Frame>

Agents can be integrated into your application using the OpenAI SDK. Each agent has a unique model identifier that you can use with any OpenAI-compatible client.

**Python Example:**

```python theme={null}
from openai import OpenAI

client = OpenAI(
    api_key="<api_key>",
    base_url="<base_url>"
)

response = client.chat.completions.create(
    model="gurubase/dd99f96a-9220-48c9-8abe-941e250dbb30",
    messages=[
        {"role": "user", "content": "Sample usage"}
    ],
    user="user_id"  # For memory tracking
)
```

Click "View Code" on any agent to see its specific integration code.

## Common Mistakes to Avoid

**Vague Trigger Conditions**: ❌ "When asking about data" → ✅ "When the user wants to do any operation regarding their address"

**Inadequate System Prompts**: ❌ "You are a helpful assistant" → ✅ "You are an assistant that manages addresses. You can either get or update addresses. You are also used for guessing the secret"

**Too Many Tools**: ❌ Selecting 20+ tools for a single agent → ✅ Select only the tools relevant to the agent's specific purpose

**Incomplete Usage Instructions**: ❌ "Use the response" → ✅ "Extract the message and reasoning from the JSON response and present them in a clear, formatted summary"

**Not Testing Agents**: ❌ Enabling agents without testing them first → ✅ Always test agents with various scenarios before enabling

**Excessive Nesting Depth**: ❌ Setting max depth to 10 without considering complexity → ✅ Start with lower depth (3-5) and increase only if needed

**Missing Output Schema**: ❌ Not defining output schema when structured data is needed → ✅ Define a clear JSON schema for consistent, parseable responses

## Next Steps

<CardGroup cols={2}>
  <Card title="Actions Guide" icon="play" href="/guides/actions">
    Learn how to create actions that agents can use as tools
  </Card>

  <Card title="API Reference" icon="code" href="/api-reference/introduction">
    Explore our API documentation for advanced integrations
  </Card>

  <Card title="Create Your First Guru" icon="robot" href="/guides/create-guru">
    Learn how to create and configure your first Guru
  </Card>

  <Card title="Prompting Your Guru" icon="message" href="/guides/prompting-your-guru">
    Learn how to customize your Guru's responses and behavior
  </Card>
</CardGroup>
