Sub Agents are currently in beta and are available starting from Rasa 3.14.0.
- ReAct Sub Agent: A built-in autonomous sub agent that has access to one or more MCP (Model Context Protocol) servers. It operates in a ReAct loop, dynamically choosing which tools to invoke based on the conversation context.
- External Sub Agent: An external sub agent connected via the A2A (Agent-to-Agent) protocol.
a2a_server block in endpoints.yml — see Exposing Rasa as an A2A Sub-Agent and A2A Server.
How Rasa Interacts with Sub Agents
Sub agents are always invoked as part of a flow execution. When a user triggers a flow that contains an autonomous step, Rasa orchestrates the sub agent interaction through a detailed process:- Agent State Check: The system checks if the sub agent is already running and in an interrupted state, resuming it if necessary.
- Agent Invocation: Rasa prepares comprehensive context data (see Context Sharing below) and invokes the sub agent sharing the created context with the sub agent.
- Retry Logic: If the sub agent encounters recoverable errors, Rasa automatically retries up to 3 times with exponential backoff.
-
Response Handling: Based on the sub agent’s response status, Rasa takes different actions:
- INPUT_REQUIRED: Response to the user with the sub agent’s message and pauses the flow to wait for user input
- COMPLETED: Response to the user and continues to the next flow step
- FATAL_ERROR: Cancels the current flow and triggers error handling
-
State Management: The system maintains sub agent state for proper resumption and cleanup, including handling interruptions when users digress to other flows or use conversation repair. When interrupted, the orchestrator:
- Pauses the sub agent’s execution
- Stores its current state and context
- Allows the new flow to proceed
- Offers to resume the interrupted sub agent when the digression is complete
- Event Integration: Any slot updates or events returned by the sub agent are integrated back into the conversation state.
Context Sharing
To ensure sub agents have the information needed to perform their tasks effectively, Rasa shares comprehensive context with each sub agent:- Current user message: The latest user input that triggered the sub agent
- Conversation history: A readable transcript of the entire conversation up to that point
- Slot values: All current slot values from the conversation, filtered to exclude system slots and include only relevant data
- Event history: The complete sequence of events that have occurred in the conversation
- Agent metadata (
AgentInput.metadata): A dictionary Rasa fills with orchestration context (for example conversation identifiers, sender and model IDs, exit conditions for task-specific agents, and A2Acontext_id/task_idwhen resuming an external agent). You can add or adjust entries inprocess_input. Values in this dictionary are not exposed to the LLM as user-visible message text; they are intended for your agent implementation and backends.
- External (A2A) agents: The full
AgentInput.metadatamap is attached to the A2AMessagesent to the remote agent (Message.metadata), alongsidecontext_idandtask_idfields derived from the well-known keyscontext_idandtask_idin that same map. Only the message parts (user text, slots payload, and so on) are shaped for the model; arbitrary metadata keys stay on the message for your A2A server to read. - ReAct (RASA) agents:
- Custom Python tools receive the agent metadata as
AgentToolContext.metadata(second argument to the tool executor). - Remote MCP tools can receive a separate
_metapayload configured per MCP server inendpoints.yml:meta_mapfor static or slot-backed non-secret contextpre_call_hookfor per-conversation secrets resolved at call time
- External (A2A) agents can resolve per-conversation secrets via
pre_call_hookin the agentconfigurationsection (merged into A2AMessage.metadata)
- Custom Python tools receive the agent metadata as
Intermediate Messages
Sub agents can send intermediate messages to users during task execution, providing real-time updates and feedback. The behavior of intermediate messages differs by sub agent type:- External sub agents: Rasa sends intermediate messages when task updates arrive with status
"submitted"or"working". - ReAct sub agents: By default, Rasa prompts the model for intermediate messages before tool execution when
enable_filler_messagesistrue(the default). Those intermediate messages are currently tool acknowledgements (short assistant text in the same LLM response as tool calls). Rasa streams the text when the output channel’s supports streaming. You can turn that off or add more messaging via customization. See Intermediate messages and Custom intermediate messages.
How to Use Sub Agents
To use sub agents in your assistant, invoke them from your flow steps using autonomous steps. An autonomous step delegates control to a sub agent for a specific part of the conversation, allowing it to reason independently using tools (such as MCP servers) or by connecting with an external agent via the A2A protocol. See Flow Steps: Autonomous Steps for details on how to configure and use this feature in your flows.Configuration
All sub agents share common configuration requirements that must be set up before they can be used in your flows.Sub Agent Directory Structure
Each sub agent must be configured in its own dedicated subdirectory within your project:sub_agents directory.
To use a different directory name, specify the sub agent directory via the CLI argument --sub-agents.
Configuration File
Every sub agent must have aconfig.yml file in its directory with the following mandatory structure:
Required Configuration Keys
The following keys are required in every sub agent’sconfig.yml:
agent.name: The name of the agent (must be unique and must not clash with any flow name)agent.description: A brief description of the sub agent’s capabilities
Optional Configuration Keys
The following common configuration keys are optional in every sub agent’sconfig.yml:
-
agent.protocol: Determines the protocol used for connections:A2Afor external sub agentsRASAfor ReAct sub agents (default)
agent.protocoltoA2A. -
configuration.module: Path to a custom module for sub agent customization.
Protocol-Specific Configuration
Theconfig.yml file contains additional settings depending on the sub agent type:
- External Sub Agents (A2A): Require an
agent_cardpath or URL. - ReAct Sub Agents (RASA): Support LLM configuration, prompt templates, timeouts, and MCP server connections.
Customization
How Rasa interacts with sub agents can be customized to fit your use case. To customize sub agents, you first need to create a custom sub agent class that inherits from the appropriate base class and overrides the necessary methods.Creating a Custom Sub Agent
The specific base class depends on the sub agent type:- ReAct Sub Agents: Inherit from
MCPOpenAgent(general-purpose) orMCPTaskAgent(task-specific) - External Sub Agents: Inherit from
A2AAgent
Input Processing Customization
Override theprocess_input method to customize how the sub agent receives and processes user input. A common use case is to filter slots so that the sub agent only receives relevant information, preventing it from being overwhelmed with unnecessary data.
The process_input method receives an AgentInput object as input:
AgentInput, which means you can modify the input that will be received by the sub agent.
Output Processing Customization
Overrideprocess_agent_output for external (A2A) sub agents to customize how responses are processed and integrated back into your system. ReAct sub agents use process_tool_output instead; that hook runs inside the ReAct loop after each tool iteration.
The process_agent_output method receives an AgentOutput object as input:
AgentOutput, which means you can modify the output created by the sub agent with more enriched information.
For protocol-specific examples, see ReAct sub agent customization and external sub agent customization.