# 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).

## New Beta Feature in 3.14

Rasa supports stateful execution of external agents via A2A protocol.

This feature is in a beta (experimental) stage and may change in future Rasa versions. We welcome your feedback on this feature.

## Overview

Rasa can act as an intelligent orchestrator that coordinates a network of multiple agents through the [Agent-to-Agent (A2A) protocol](https://a2a-protocol.org/latest/#what-is-a2a-protocol). This is particularly useful when at least one of the agents is externally built, i.e. by a different department, by a third party, or it's a legacy project on a different tech stack. Integrating each of these agents into a single system enables contextually rich conversations through single unified conversational interface.

### Inverse role — Rasa as an A2A sub-agent

This guide covers Rasa as the **orchestrator** that calls **external** A2A agents. If you need the opposite — an external orchestrator calling **your** Rasa assistant — see [Exposing Rasa as an A2A Sub-Agent](/content/docs/pro/build/exposing-rasa-as-a2a-sub-agent/index.html) and the [A2A Server reference](/content/docs/reference/integrations/a2a-server/index.html).

## The Orchestrator Model

In this architecture, your Rasa agent serves as the **orchestrator** that:

1. **Owns the conversation flow** - Determines when and which external agents to involve
2. **Manages business logic** - Enforces business rules, compliance, and conversation patterns
3. **Controls agent handoffs** - Decides when to delegate tasks and when to resume control
4. **Maintains conversation context** - Preserves user context across different agent interactions
5. **Allows context engineering** - Allows fine-grained control over context passed between agents
6. **Handles final responses** - Ensures consistent user experience regardless of which agent provided the information

## Configuring External Sub-Agents

### Registering the sub agent

Configure external sub agents in the `sub_agents/` folder of your Rasa agent:

```txt
your_project/
├── config.yml
├── domain/
├── data/flows/
└── sub_agents/
    ├── analytics_agent/
       └── config.yml
```

The A2A protocol prescribes using an [agent card](https://a2a-protocol.org/latest/specification/#55-agentcard-object-structure) to expose any externally running agent's capabilities. The agent card can be provided as part of the `config.yml` defined for each external agent -

sub_agents/analytics_agent/config.yml

```yaml
# Basic agent information
agent:
  name: analytics_agent
  protocol: a2a
  description: "External agent that provides analytical capabilities"

# A2A configuration
configuration:
  agent_card: ./sub_agents/shopping_agent/agent_card.json
```

More configuration options can be found in the [reference page](/content/docs/reference/config/agents/external-sub-agents/#configuration/index.html).

### Supporting long-running tasks

If the external A2A agent performs long-running work, configure background push mode so Rasa can keep the conversation responsive while the remote task continues. The external agent card must advertise `capabilities.pushNotifications: true`, and the sub-agent configuration must include the public Rasa base URL: The `agent_card` value can be a local file path or a URL.

sub_agents/analytics_agent/config.yml

```yaml
agent:
  name: analytics_agent
  protocol: A2A
  description: "External agent that provides analytical capabilities"

configuration:
  agent_card: ./sub_agents/analytics_agent/agent_card.json
  push_notification_url: https://rasa.example.com
```

Rasa appends `/agent/task_update` to `push_notification_url`. When a background A2A task is still running and the user sends another message, Rasa triggers `pattern_external_agent_processing`; the default response is `utter_agent_busy`.

For channel-specific delivery behavior and fallback behavior, see [Long-running tasks with push notifications](/content/docs/reference/config/agents/external-sub-agents/#long-running-tasks-with-push-notifications/index.html).

## Invoking the External Agent

The orchestrating layer in Rasa provides you the control to invoke an external agent when your business logic needs you to do so by using the [`call` step](/content/docs/reference/primitives/flow-steps/#autonomous-steps/index.html) in a flow -

flows.yml

```yaml
flows:
  product_enquiry:
    description: Handle questions related to analysis needed on the product
    steps:
    - collect: query
    - call: analytics_agent  # External A2A agent
```

For more information on how Rasa passes control and receives response from an external agent via A2A, head over to the documentation on [External Sub Agents](/content/docs/reference/config/agents/overview-agents/#how-rasa-interacts-with-sub-agents/index.html).

## Context Management

The orchestrating agent in Rasa can control what context is shared with external agents by customizing the client interfacing with the external agent.

To do so, define a custom python module -

sub_agents/analytics_agent/custom_agent.py

```python
from rasa.agents.protocol.a2a.a2a_agent import A2AAgent
from rasa.agents.schemas import AgentInput

class AnalyticsAgent(A2AAgent):
    async def process_input(self, input: AgentInput) -> AgentInput:
        # Filter slots to only include relevant context
        filtered_slots = [\
            slot for slot in input.slots\
            if slot.name in ["user_id", "account_type", "inquiry_category"]\
        ]

# Create new input with filtered context
        return AgentInput(
            id=input.id,
            user_message=input.user_message,
            slots=filtered_slots,  # Only share necessary slots
            conversation_history=input.conversation_history,
            events=input.events,
            metadata=input.metadata,
            timestamp=input.timestamp
        )
```

Provide the customized interface to your sub agent's config:

sub_agents/analytics_agent/config.yml

```yaml
agent:
  name: analytics_agent
  protocol: a2a
  description: "External agent that provides analytical capabilities"

configuration:
  agent_card: ./sub_agents/analytics_agent/agent_card.json
  module: sub_agents.analytics_agent.custom_agent.AnalyticsAgent
```

For more information on possible customizations, head over to the [reference documentation](/content/docs/reference/config/agents/external-sub-agents/#customization/index.html).
