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

# Agents in Flows

> Use an agent as a step, and act on what it returns

Drop an agent into a [flow](https://www.activepieces.com/docs/flows/building-flows.md) as a step. The flow handles what's certain, the agent handles the rest.

## What people use it for

> [card] Research
>
> Looks up a lead and returns a brief with a fit score.

> [card] Triage
>
> Reads an email, classifies it, sets the urgency.

> [card] Action
>
> Files the invoice, updates the system, posts the summary.

> [!TIP]
>
> If you can write the rule in one sentence without saying "depends", it's a condition, not an agent.

## Run one of your saved agents

Add a **Run Agent** step from the **AI** piece, then pick the agent in **Agent**. Its instructions, tools and model come from the agent, so leave **AI Model** empty. An agent marked **Not published yet** is listed too, but a flow can only run it once it's published.

**1. The step runs the published agent**

Edits you make to the agent reach your flows once you publish them from the agent's Configure panel. Until then, flows keep running the version that was live.

**2. Each run shows up on the agent**

The agent's **Runs** tab lists the runs flows started, with the flow that triggered each one. A run refused before it started isn't listed.

**3. A published flow keeps the agent in place**

While a published flow runs the agent, it can't be deleted or moved to another project. The dialog links the flows that use it (members who can't read flows see a count instead). Take the agent out of each flow and publish the flow, then try again.

## Get a result you can build on

Prose is hard to branch on, because the phrasing drifts every run.

> "This looks fairly urgent, someone should pick it up today."

Ask for **structured output** instead and you get fields:

| Field | Type | Example |
| - | - | - |
| `category` | Text | `billing` |
| `urgency` | Number | `4` |
| `needs_human` | Boolean | `true` |

Later steps pick these up from the [data selector](https://www.activepieces.com/docs/flows/passing-data.md), the same as any other step's output. Route on `needs_human`, sort by `urgency`, drop `category` into the Slack message.

> [!TIP]
>
> Ask for the fewest fields the next step needs. Every extra field is one more thing to get wrong.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.