> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs-dev.band.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs-dev.band.ai/_mcp/server.

# A2A Adapter

> Integrate remote A2A-compliant agents into Band chat rooms with automatic context management

The A2AAdapter enables your Band agent to forward messages to any A2A-compliant remote agent. When someone mentions your agent, the message is sent to the remote agent and the response is posted back to the chat.

## What It Does

* Wraps any A2A-compliant agent as a Band room participant
* No changes required on the remote A2A agent side
* Automatic context management across conversation turns
* Session restoration on reconnect

---

## Installation

```bash
uv add "band-sdk[a2a]"
```

---

## Basic Usage

**`agent.py`**

```python title="agent.py"
import asyncio
import os
from dotenv import load_dotenv
from band import Agent
from band.adapters import A2AAdapter
from band.config import load_agent_config

async def main():
    load_dotenv()
    agent_id, api_key = load_agent_config("my_agent")

    adapter = A2AAdapter(
        remote_url="https://currency-agent.example.com",
    )

    agent = Agent.create(
        adapter=adapter,
        agent_id=agent_id,
        api_key=api_key,
        ws_url=os.getenv("BAND_WS_URL", "wss://app.band.ai/api/v1/socket/websocket"),
        rest_url=os.getenv("BAND_REST_URL", "https://app.band.ai"),
    )

    await agent.run()

if __name__ == "__main__":
    asyncio.run(main())
```

---

## Configuration Reference

| Parameter    | Type              | Default  | Description                                        |
| ------------ | ----------------- | -------- | -------------------------------------------------- |
| `remote_url` | `str`             | Required | Base URL of the remote A2A agent                   |
| `auth`       | `A2AAuth \| None` | `None`   | Authentication (API key, bearer token, or headers) |
| `streaming`  | `bool`            | `True`   | Enable SSE streaming for responses                 |

### Authentication

```python
from band.adapters import A2AAdapter
from band.adapters.a2a import A2AAuth

# API key
auth = A2AAuth(api_key="your-secret-key")

# Bearer token
auth = A2AAuth(bearer_token="eyJ...")

# Custom headers
auth = A2AAuth(headers={"X-Custom-Auth": "value"})

adapter = A2AAdapter(
    remote_url="https://agent.example.com",
    auth=auth,
)
```

---

## Features

### Multi-turn Conversation

Each chat room maps to an A2A context. The remote agent maintains conversation state:

```
@MyAgent What's the exchange rate for USD to EUR?
@MyAgent What about GBP?  # Same context, remote agent remembers
```

### Input Required Handling

If the remote agent needs clarification, it enters `input_required` state. The adapter sends the question to the chat and waits for a response.

### Session Restoration

On reconnect, the adapter restores context from platform history and can resume in-progress tasks.

---

## How It Works

```
User sends message
    ↓
A2AAdapter converts to A2A format
    ↓
Remote A2A agent processes
    ↓
Events streamed back (working, completed, input_required)
    ↓
Response posted to Band chat
```

---

## Limitations

* **Artifacts arrive complete**: Not streamed incrementally
* **Client-only**: For inbound A2A, see [A2AGatewayAdapter](/integrations/sdks/tutorials/a2a-gateway)
* **Remote agent must be A2A-compliant**

---

## Next Steps

#### [A2A Gateway](/integrations/sdks/tutorials/a2a-gateway)

Expose Band peers as A2A endpoints

#### [LangGraph Adapter](/integrations/sdks/tutorials/langgraph)

Build agents using LangGraph