# Use AI··Agent

import { Steps } from "@astrojs/starlight/components"

An **AI··Agent** in a flow is another Mindflow flow with a **Flowhook** trigger and a **Success** output that you
attach on an **AI··Task** **Agents** tab. The model decides when to call that agent, passes Flowhook parameters, and
uses the Success payload to continue. This is different from integration **Tools** (vendor APIs) and from a fixed
**Call a flow** step. Screenshots on this page use a **Mathematics Teacher** agent and a **Draft remediation plan**
parent so you can see the agent contract and the Agents tab.

## When to use

- An AI··Task should choose whether (and when) to call a specialized subflow.
- You want a typed Flowhook input and Success output the model can reason about from the flow name and description.
- Prefer [Call a flow](../../control-flow-execution/call-a-flow/) when the parent must always call the other flow in a
  fixed place in the graph.
- Prefer [AI··Task: A simple guide](../ai-task-a-simple-guide/) for service tools (VirusTotal, Workspace, and similar).
- Prefer [AI··Swarms](../ai-swarms-multi-agent-orchestration/) when several workers collaborate under one orchestrator.

Before you begin, you need permission to create and deploy flows in the environment. The **Agents** tab appears on
AI··Task when agentic flow tools are enabled for your organization.

## Guide

### Build the AI··Agent flow

The called flow needs a clear **name** and **description** (the model uses them), a **Flowhook** that defines input
fields, the work steps (often an AI··Task), and a **Success** step that defines the returned schema.

<ol>
<li>

**Create the flow.** Name and describe it for the job (for example **Mathematics Teacher**). Deploy it to the
environment where the parent AI··Task will run.

</li>
<li>

**Add Flowhook first.** Define the parameters the orchestrator will pass (for example **Problem**).
<div class="docs-screenshot-compact">

![Mathematics Teacher canvas with Receive problem Flowhook, Solve the problem AI··Task, and Return answer Success](./assets/agent-flow-canvas.png)

</div>
<div class="docs-screenshot-compact">

![Receive problem Flowhook Settings with required Problem string property](./assets/flowhook-contract.png)

</div>

</li>
<li>

**Add the work and Success.** Complete the middle steps, then set **Success** so the returned fields match what the
orchestrator should receive (for example **Answer**).
<div class="docs-screenshot-compact">

![Return answer Success Output with Answer set to 42](./assets/success-output.png)

</div>

</li>
</ol>
### Attach the agent on an AI··Task

On the parent flow, an AI··Task that can use tools lists an **Agents** tab. Only flows with a Flowhook appear in the
picker (same rule as Call a flow).

<ol>
<li>

**Open Agents.** Select the orchestrator AI··Task, then open the **Agents** tab.

</li>
<li>

**Add an agent.** Use **Add an agent**, pick the Flowhook-based flow and version, then save. Give the AI··Task a
prompt that explains when to call that agent.
<div class="docs-screenshot-compact">

![Draft remediation plan AI··Task Agents tab with Mathematics Teacher attached](./assets/agents-tab.png)

</div>

</li>
<li>

**Run and inspect Logs.** After a run, open **Logs** on the AI··Task to see agent invocations, the request sent to
the Flowhook, and the Success response.

</li>
</ol>
## Example

A parent AI··Task on **Draft remediation plan** drafts a remediation plan and calls **Mathematics Teacher** only when
the user message includes a calculation. The worker accepts **Problem** on its Flowhook, solves it in an AI··Task, and
returns **Answer** from **Success**. The parent prompt lists the agent under resources and tells the model to call it
for math, then continue with the remediation plan.

## Keep in mind

- Name and describe the agent flow carefully—the model relies on that metadata when choosing tools.
- Attaching one or more agents puts the AI··Task into swarm-style coordination; see
  [AI··Swarms](../ai-swarms-multi-agent-orchestration/) for orchestrator/worker patterns.
- Service APIs stay on the **Tools** tab; agent flows stay on the **Agents** tab.

## Related

- [AI··Task: A simple guide](../ai-task-a-simple-guide/)
- [AI··Swarms: Multi-agent orchestration](../ai-swarms-multi-agent-orchestration/)
- [Call a flow](../../control-flow-execution/call-a-flow/)
