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

# Multi-Agent Workflows

> Set up orchestrator agents that delegate to specialized subagents.

# Multi-Agent Workflows

Multi-agent workflows allow a single user-facing agent (the **orchestrator**) to delegate tasks to multiple specialized **subagents**. This is useful when your organization has distinct knowledge domains or toolsets that benefit from dedicated agents.

## How it works

```
User → Orchestrator Agent
              ├── HR Subagent (HR knowledge base, HR tools)
              ├── Engineering Subagent (technical docs, code execution)
              └── Finance Subagent (financial reports, spreadsheets)
```

1. The user sends a message to the orchestrator
2. The orchestrator analyzes the request and determines which subagent can best handle it
3. The request is delegated to the appropriate subagent
4. The subagent processes the request using its own tools and knowledge bases
5. The orchestrator receives the subagent's response and returns it to the user

The user only interacts with the orchestrator — they don't need to know about or select individual subagents.

## Setting up a multi-agent workflow

<Steps>
  <Step title="Create subagents">
    First, create the individual specialized agents that will serve as subagents. Each should have:

    * A focused knowledge base for its domain
    * Tools relevant to its area
    * A clear system prompt defining its expertise
  </Step>

  <Step title="Create the orchestrator">
    Create a new agent and configure it as an orchestrator. In the agent configuration:

    * Select **Multi-Agent** as the agent type
    * Add the subagents you created in the previous step
    * Write a system prompt that describes when to delegate to each subagent
  </Step>

  <Step title="Configure delegation rules">
    The orchestrator's system prompt should clearly define routing logic:

    ```
    You are the main assistant for Acme Corp. Route questions as follows:
    - HR, benefits, policies → delegate to HR Assistant
    - Technical documentation, code → delegate to Engineering Bot
    - Financial reports, budgets → delegate to Finance Assistant
    If a question spans multiple areas, consult the relevant subagents 
    and synthesize their responses.
    ```
  </Step>

  <Step title="Test the workflow">
    Start a chat with the orchestrator and test questions that should route to different subagents. Verify that:

    * Questions are routed to the correct subagent
    * Responses include citations from the right knowledge bases
    * Cross-domain questions are handled gracefully
  </Step>
</Steps>

## Best practices

* **Keep subagents focused** — Each subagent should be an expert in one area
* **Write clear routing instructions** — The orchestrator's system prompt should leave no ambiguity about which subagent handles what
* **Limit the number of subagents** — 3–5 subagents is typically optimal; too many can confuse the routing
* **Test edge cases** — Try ambiguous questions that could go to multiple subagents
