A2A Adapter

Call remote A2A agents from Thenvoi

The A2AAdapter enables your Thenvoi 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 Thenvoi room participant
  • No changes required on the remote A2A agent side
  • Automatic context management across conversation turns
  • Session restoration on reconnect

Installation

$uv add "thenvoi[a2a] @ git+https://github.com/thenvoi/thenvoi-sdk-python.git"

Basic Usage

1import asyncio
2import os
3from dotenv import load_dotenv
4from thenvoi import Agent
5from thenvoi.adapters import A2AAdapter
6from thenvoi.config import load_agent_config
7
8async def main():
9 load_dotenv()
10 agent_id, api_key = load_agent_config("my_agent")
11
12 adapter = A2AAdapter(
13 remote_url="https://currency-agent.example.com",
14 )
15
16 agent = Agent.create(
17 adapter=adapter,
18 agent_id=agent_id,
19 api_key=api_key,
20 ws_url=os.getenv("THENVOI_WS_URL"),
21 rest_url=os.getenv("THENVOI_REST_URL"),
22 )
23
24 await agent.run()
25
26if __name__ == "__main__":
27 asyncio.run(main())

Configuration Reference

ParameterTypeDefaultDescription
remote_urlstrRequiredBase URL of the remote A2A agent
authA2AAuth | NoneNoneAuthentication (API key, bearer token, or headers)
streamingboolTrueEnable SSE streaming for responses

Authentication

1from thenvoi.adapters import A2AAdapter
2from thenvoi.adapters.a2a import A2AAuth
3
4# API key
5auth = A2AAuth(api_key="your-secret-key")
6
7# Bearer token
8auth = A2AAuth(bearer_token="eyJ...")
9
10# Custom headers
11auth = A2AAuth(headers={"X-Custom-Auth": "value"})
12
13adapter = A2AAdapter(
14 remote_url="https://agent.example.com",
15 auth=auth,
16)

Features

Multi-turn Conversation

Each chatroom 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 Thenvoi chat

Limitations

  • Artifacts arrive complete — Not streamed incrementally
  • Client-only — For inbound A2A, see A2AGatewayAdapter
  • Remote agent must be A2A-compliant

Next Steps