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

# Agents

> Autonomous AI agents that can reason, plan, and interact with various tools to complete complex tasks.

<Note>
  Before diving into Agents, you should have a basic understanding of Cortex workflows. If you haven't already, we recommend familiarizing yourself with creating your first workflow and understanding workflow steps.

  <CardGroup cols={2}>
    <Card title="Your First Workflow" icon="diagram-project" href="/workflows/your-first-workflow" color="purple">
      Learn the fundamentals of building workflows in Cortex
    </Card>

    <Card title="Steps" icon="gears" href="/workflows/steps/overview" color="green">
      Understand the different types of steps and how they work together
    </Card>
  </CardGroup>
</Note>

Workflow Agents transform your models into autonomous, reasoning systems that interact with tools to perform complex tasks with minimal setup. Connect tools to your model step, provide clear instructions, and watch as the agent orchestrates a sophisticated chain of actions to accomplish your goals.

## What Makes Agents Magical?

Unlike traditional workflow steps that execute in a predefined sequence, agents:

* **Reason dynamically** about which tools to use and when
* **Self-correct** when encountering obstacles
* **Execute chain-of-thought reasoning** to break down complex problems
* **Autonomously fill fields** across connected tools
* **Make decisions** based on real-time information

## Creating Your First Agent: Deep Research Assistant

Let's build something impressive—a comprehensive research assistant that can search the web, browse pages, compare sources, and create a polished report for you. This single agent can accomplish what would typically require complex code or multiple manual steps.

### Create the Input

First, add an **Input** step with a text field for the research topic.

<img src="https://mintcdn.com/cortex-891fd898/4MLfFrvXy66YjKyF/assets/workflows/agents/research-input-step.png?fit=max&auto=format&n=4MLfFrvXy66YjKyF&q=85&s=5bc7e8f2947584297916261a4c9716b0" alt="Screenshot of the input step with a text field named 'research_topic'" style={{ borderRadius: '10px' }} width="2918" height="1612" data-path="assets/workflows/agents/research-input-step.png" />

### Add Your Model Step

Add a **Model** step connected to the Input step. This will become your agent.

<img src="https://mintcdn.com/cortex-891fd898/4MLfFrvXy66YjKyF/assets/workflows/agents/research-model-step.png?fit=max&auto=format&n=4MLfFrvXy66YjKyF&q=85&s=be921b651e03ac6a1755afe90df6a39a" alt="Screenshot of a model step connected to the input step" style={{ borderRadius: '10px' }} width="2918" height="1612" data-path="assets/workflows/agents/research-model-step.png" />

### Connect Agent Tools

Here's where the magic begins. Unlike regular workflow steps that connect left-to-right, agent tools connect **vertically below** the model step through the robot icon. This indicates these tools belong to and are controlled by this specific agent.

Connect these three steps as tools to your model:

* **Web Search**
* **Browser**
* **Markdown to PDF**

<video controls src="https://mintcdn.com/cortex-891fd898/4MLfFrvXy66YjKyF/assets/workflows/agents/connect-tools.mp4?fit=max&auto=format&n=4MLfFrvXy66YjKyF&q=85&s=465de1b0bd70e99aaaa0339291662486" muted style={{ borderRadius: '10px' }} alt="Video showing three steps connecting as tools below the model step via the robot icon" data-path="assets/workflows/agents/connect-tools.mp4" />

### Enable AI Auto-Fill for Tool Fields

For each connected tool, set key fields to **Auto**:

1. **Web Search tool**:

   * Set "Search Engine" to Auto (lets the agent choose between Google, Bing, etc.)
   * Set "Query" to Auto (agent will formulate specific search queries)

2. **Browser step**:

   * Set "URL" to Auto (agent will decide which pages to visit based on search results)

3. **Markdown to PDF tool**:
   * Set "Markdown Source" to Auto (agent will create the report content)
   * Set "Filename" to Auto (agent will name the file appropriately)

<video controls src="https://mintcdn.com/cortex-891fd898/4MLfFrvXy66YjKyF/assets/workflows/agents/auto-fill-fields.mp4?fit=max&auto=format&n=4MLfFrvXy66YjKyF&q=85&s=58adb728956ba6a7cee966644e9a2ffc" muted style={{ borderRadius: '10px' }} alt="Video showing the Auto option being selected for various tool fields" data-path="assets/workflows/agents/auto-fill-fields.mp4" />

When you select "Auto" for a field, the agent will determine the optimal value at runtime based on its reasoning.

### Enable Error Recovery

Open the model step options menu and select "Continue on Error" from the context menu. This allows the agent to recover when tools fail.

<img src="https://mintcdn.com/cortex-891fd898/4MLfFrvXy66YjKyF/assets/workflows/agents/continue-on-error.png?fit=max&auto=format&n=4MLfFrvXy66YjKyF&q=85&s=87f24c9b5cd4e7486579bacc2664f0c6" alt="Screenshot showing the 'Continue on Error' option being enabled in the context menu of a model step" style={{ borderRadius: '10px' }} width="2238" height="1340" data-path="assets/workflows/agents/continue-on-error.png" />

For example, if the browser tool fails to access a page due to restrictions, the agent can:

1. Recognize the failure
2. Try alternative sources
3. Continue its research using other available information
4. Still complete its task successfully

### Add Your Prompt

In the model step, add this simple prompt:

<img src="https://mintcdn.com/cortex-891fd898/4MLfFrvXy66YjKyF/assets/workflows/agents/add-prompt.png?fit=max&auto=format&n=4MLfFrvXy66YjKyF&q=85&s=180ce15828844c6aed1467f61ee43176" alt="Screenshot showing the prompt being added to the model step" style={{ borderRadius: '10px' }} width="2206" height="1318" data-path="assets/workflows/agents/add-prompt.png" />

```
Research this topic thoroughly: {{input1.output.research_topic}}

Use search and browser tools to find reliable information. Compare perspectives, verify facts across multiple sources, and create a comprehensive report with citations. Convert your findings to PDF and provide the link to download it.
```

That's it! With just these few lines, the agent knows exactly what to do.

### Run Your First Agent!

Run the workflow with any research topic and watch the magic unfold! Your agent autonomously breaks down the topic, formulates search queries, browses websites, compares perspectives, verifies facts, and delivers a comprehensive, well-organized PDF report—all without any further input from you.

## Monitoring Agent Actions

When your agent runs, you can observe its reasoning and tool usage:

1. The **Output** section shows the agent's thinking process
2. The **Calls** tab displays each tool invocation with input parameters and results

<img src="https://mintcdn.com/cortex-891fd898/4MLfFrvXy66YjKyF/assets/workflows/agents/agent-calls-tab.png?fit=max&auto=format&n=4MLfFrvXy66YjKyF&q=85&s=b5861593e12d55cda09417919b1e0e8f" alt="Screenshot of the Calls tab showing a list of tool calls made by the agent, including search queries and browser URLs" style={{ borderRadius: '10px' }} width="2044" height="1314" data-path="assets/workflows/agents/agent-calls-tab.png" />

## Agent Configuration

In the Model step settings, you'll find special options for agents:

* **Tools Mode**:
  * **Auto**: Agent decides when to use tools (recommended)
  * **Required**: Agent must always use tools
  * **None**: Agent does not use tools
* **Tools Parallel**: Enable parallel execution of multiple tools
* **Max Iterations**: Set the maximum number of tool-calling cycles

<img src="https://mintcdn.com/cortex-891fd898/4MLfFrvXy66YjKyF/assets/workflows/agents/agent-settings.png?fit=max&auto=format&n=4MLfFrvXy66YjKyF&q=85&s=218329638fdce8a6081a3a109a0ced23" alt="Screenshot of the model step settings panel showing tools mode dropdown set to Auto, Tools Parallel toggle enabled, and Max Iterations slider set to 50" style={{ borderRadius: '10px' }} width="1780" height="1122" data-path="assets/workflows/agents/agent-settings.png" />

## Automated Email Response System

Let's see another example. We'll build a complete email processing system. Every time an email arrives, the agent analyzes it, crafts a personalized response, sends it, and notifies your team—all autonomously and within minutes of setup.

* **On Receive Email** trigger
* **Model** agent with tools:
  * Send Email Reply
  * Inform Team (Slack notification)

<img src="https://mintcdn.com/cortex-891fd898/4MLfFrvXy66YjKyF/assets/workflows/agents/email-response-example.png?fit=max&auto=format&n=4MLfFrvXy66YjKyF&q=85&s=cffe46fcb38748f81cec2cb9035a284a" alt="Screenshot of an email automation workflow with an 'On Receive Email' trigger connected to a model step, which has 'Send Email Reply' and 'Inform Team' tools connected underneath it" style={{ borderRadius: '10px' }} width="1638" height="1352" data-path="assets/workflows/agents/email-response-example.png" />

```
You received an email from {{onReceiveEmail.output.from}} with subject "{{onReceiveEmail.output.subject}}".

Generate and send a helpful response. Then notify our team in Slack with a brief summary.
```

## Multiple Agents in One Workflow

While a single agent can handle complex tasks on its own, you can also use multiple agents in one workflow for specialized tasks:

* Research agent with specialized search tools
* Analysis agent with data processing capabilities
* Communication agent with email and notification tools

This modular approach allows you to create specialized agents for different workflow stages, though in many cases, a well-configured single agent can accomplish what might otherwise require multiple steps.

## Start Building Magical Agents Today

This guide has introduced you to the fundamentals of Cortex agents. Now it's time to build your own intelligent agents for your unique use cases and experience their transformative capabilities firsthand. Our platform continuously expands with new integrations and capabilities, empowering you to create increasingly sophisticated automated workflows that adapt to your business needs.
