# Build your first agent in just a few minutes with [Rasa Copilot](https://hello.rasa.com/?utm_source=docs&utm_medium=referral&utm_campaign=docs_cta).

## On this page

ReAct Sub Agents are currently in **beta** and are available starting from **Rasa 3.14.0**.

ReAct sub agents are built-in autonomous agents that can dynamically utilize [MCP (Model Context Protocol)](https://modelcontextprotocol.io/docs/getting-started/intro) tools and custom tools defined in Python code to complete tasks. They follow a [ReAct](https://arxiv.org/abs/2210.03629) ( **re** asoning + **act** ing) loop: a large language model (LLM) chooses which tools to invoke based on the ongoing conversation context.

Two types of ReAct sub agents are currently supported:

1. **[General-purpose ReAct Sub Agent](/content/docs/reference/config/agents/react-sub-agents/#general-purpose-react-sub-agent/index.html)**: Handles open-ended tasks and requires explicit completion signaling
2. **[Task-specific ReAct Sub Agent](/content/docs/reference/config/agents/react-sub-agents/#task-specific-react-sub-agent/index.html)**: Focuses on filling specific slots with automatic completion based on exit conditions

## General-purpose ReAct Sub Agent

A general-purpose ReAct sub agent is designed for open-ended, exploratory tasks where the agent itself determines when the task is complete. Unlike task-specific agents that have predefined exit conditions, general-purpose agents require explicit completion signaling through a built-in [`task_completed` tool](/content/docs/reference/config/agents/react-sub-agents/#the-task_completed-tool/index.html).

### Key Characteristics

- **Open-ended tasks**: Handles exploratory conversations and complex, multi-step tasks
- **Autonomous completion**: The agent decides when it has fully completed its assigned task
- **Explicit signaling**: Uses the built-in [`task_completed` tool](/content/docs/reference/config/agents/react-sub-agents/#the-task_completed-tool/index.html) to signal completion
- **No exit conditions**: Invoked via [autonomous call steps without exit conditions](/content/docs/reference/primitives/flow-steps/#autonomous-steps/index.html)

### The `task_completed` Tool

General-purpose ReAct sub agents have access to a built-in `task_completed` tool that ends the ReAct loop and returns control to the flow. The tool is registered automatically and always uses the name `task_completed` so the runtime can recognize completion. The tool has **no parameters**. When calling `task_completed`, the model should include a short, natural user-facing message in the same response. This message appears directly to the user and serves as a brief closing line for that turn.

You can change or replace this tool by subclassing `MCPOpenAgent` and overriding [`get_task_completed_tool()`](/content/docs/reference/config/agents/react-sub-agents/#customizing-the-task_completed-tool-and-empty-final-messages/index.html).

#### Tool definition

task_completed tool schema

```json
{
  "type": "function",
  "function": {
    "name": "task_completed",
    "description": "Call this tool exactly once when your primary task is FULLY completed. This tool accepts no arguments. You MUST also include text in the same response: a natural, conversational follow-up to the user's last message (e.g. acknowledge their choice, wish them well, close warmly). Do NOT summarize what you did or what happened in the conversation. Do NOT include any inner thoughts or explanations. A response with only the tool call and no text is invalid. Keep it short and natural.",
    "parameters": {
      "type": "object",
      "properties": {},
      "additionalProperties": false
    },
    "strict": true
  }
}
```

### How Completion Works

1. **Agent decision**: The ReAct sub agent autonomously determines when its primary task is complete and the execution loop should finish.
2. **Tool call**: When ready to complete, the model calls the `task_completed` tool once. The tool has no parameters; the closing line for the user is agent message in the same turn (a short follow-up to the user’s last message—not a recap of the whole conversation, and not a message argument on the tool).
3. **Completion signal**: The `task_completed` call terminates the ReAct sub agent’s execution loop. If the model also invoked other MCP tools in that same response, Rasa still processes those tool results before the run completes. The run ends with status `completed`.
4. **User response**: The user sees the streamed agent message from that turn. The tool itself only returns a fixed internal result (`Task completed`); that value is not a user-facing parameter.
5. **Control return**: Control returns to the main flow, which can then proceed to the next step.

## Task-specific ReAct Sub Agent

A task-specific ReAct sub agent is designed for structured data collection tasks where specific slots need to be filled with values. Unlike general-purpose agents that determine their own completion, task-specific agents automatically complete when predefined exit conditions are met, making them ideal for appointment booking, form filling, or data collection scenarios.

### Key Characteristics

- **Structured data collection**: Focuses on filling specific slots with values.
- **Automatic completion**: Completes when exit conditions are satisfied.
- **Built-in slot tools**: Automatically gets [`set_slot_<slot_name>` tools](/content/docs/reference/config/agents/react-sub-agents/#the-set_slot_slot_name-tools/index.html) for each slot in exit conditions.
- **Exit condition driven**: Invoked via [autonomous call steps with `exit_if` conditions](/content/docs/reference/primitives/flow-steps/#specifying-exit-conditions/index.html).

### The `set_slot_<slot_name>` Tools

Task-specific ReAct sub agents automatically receive built-in `set_slot_<slot_name>` tools for each slot mentioned in the `exit_if` conditions. These tools are dynamically generated based on the slot definitions and cannot be disabled.

### Configuration

ReAct sub agents extend the [basic sub agent configuration](/content/docs/reference/config/agents/overview-agents/#configuration/index.html) with additional settings.

#### Configuration Section

The `configuration` section is optional in the ReAct sub agent's `config.yml` file and provides additional customization options for LLM and connection settings.

- **`configuration.llm`**: Defines which Large Language Model (LLM) powers the ReAct sub agent's reasoning and tool use. The configuration format matches the standard used for other Rasa LLM settings.
- **`configuration.prompt_template`**: Path to a Jinja2 template for [customizing the prompt](/content/docs/reference/config/agents/react-sub-agents/#modifying-the-prompt-template/index.html) of this ReAct sub agent.
- **`configuration.timeout`**: Specifies how many seconds to wait before timing out autonomous sub agent execution.
- **`configuration.max_retries`**: Number of retry attempts if MCP server connection fails.
- **`configuration.include_date_time`**: Enable or disable datetime information in prompts.
- **`configuration.timezone`**: A valid IANA timezone name.

### Customization

ReAct sub agents can be customized in two ways:

- [Modifying the Prompt Template](/content/docs/reference/config/agents/react-sub-agents/#modifying-the-prompt-template/index.html)
- [Customizing the Runtime Engine](/content/docs/reference/config/agents/react-sub-agents/#customizing-the-runtime-engine/index.html)

### Key Differences Between General-Purpose and Task-Specific ReAct Sub Agents

| Category | General-Purpose | Task-Specific |
| --- | --- | --- |
| **Purpose** | Open-ended exploratory conversations where the agent determines when it is done | Goal-oriented tasks that need to fill specific slots with values |
| **Completion** | Requires calling a `task_completed` tool to finish its execution loop | Automatically completes when exit conditions are met |
| **Exit Conditions** | Explicit signaling of completion via the `task_completed` tool | Completion determined by evaluating the `exit_if` conditions |
| **Built-in Slot Tools** | No automatic slot-setting tools | Automatically gets `set_slot_<slot_name>` tools for each slot mentioned in the exit conditions |
| **Final response** | The model sends agent message (short closing follow-up to the user’s last message) in the same turn as a `task_completed` tool call; the tool has no parameters and only signals that the run is done | Completes silently without sending a response, allowing the flow to continue to the next step |
