Skip to content

API Reference parrot.a2a.mixin

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.a2a.mixin

View source

A2A Client Mixin - Add A2A client capabilities to AI-Parrot agents.

This mixin enables agents to:

  • Connect to remote A2A agents directly
  • Discover agents from a centralized mesh
  • Use remote agents as callable tools
  • Integrate with Router and Orchestrator for complex workflows

Alias A2AAgentConnection

Re-exported from parrot.a2a.client.A2AAgentConnection.

Alias A2AClient

Re-exported from parrot.a2a.client.A2AClient.

Class A2AClientMixin

Mixin to add A2A client capabilities to any AbstractBot.

This allows an agent to communicate with remote A2A agents, either directly or by registering them as tools.

Parameter Type Default Description
*args ()
**kwargs {}

Method A2AClientMixin.set_matrix_transport

Set a Matrix-based A2A transport.

When configured, the agent can use Matrix rooms for A2A communication instead of (or in addition to) HTTP.

set_matrix_transport(transport: Any) -> None

Parameter Type Default Description
transport Any MatrixA2ATransport instance.

Method A2AClientMixin.get_matrix_transport

Get the configured Matrix A2A transport.

get_matrix_transport() -> Optional[Any]

Returns: Optional[Any]

Method A2AClientMixin.set_mesh

Connect this agent to an A2A mesh discovery service.

The mesh provides centralized discovery and health checking of remote A2A agents.

set_mesh(mesh: 'A2AMeshDiscovery') -> None

Parameter Type Default Description
mesh 'A2AMeshDiscovery' A2AMeshDiscovery instance

Method A2AClientMixin.get_mesh

Get the connected mesh discovery service.

get_mesh() -> Optional['A2AMeshDiscovery']

Returns: Optional['A2AMeshDiscovery']

Method A2AClientMixin.discover_from_mesh

Discover and connect to agents from the mesh.

Queries the mesh for agents matching the criteria and establishes connections to them.

discover_from_mesh(skill: Optional[str] = None, tag: Optional[str] = None, register_as_tools: bool = True) -> List[A2AAgentConnection]

Parameter Type Default Description
skill Optional[str] None Filter by skill ID
tag Optional[str] None Filter by tag
register_as_tools bool True If True, register discovered agents as tools

Returns: List[A2AAgentConnection] — List of new connections established

Method A2AClientMixin.set_router

Set an A2A router for rule-based message routing.

The router enables deterministic routing based on skills, tags, or regex patterns without LLM involvement.

set_router(router: 'A2AProxyRouter') -> None

Parameter Type Default Description
router 'A2AProxyRouter' A2AProxyRouter instance

Method A2AClientMixin.get_router

Get the connected router.

get_router() -> Optional['A2AProxyRouter']

Returns: Optional['A2AProxyRouter']

Method A2AClientMixin.route_to_agent

Route a message to an agent using the configured router.

Uses rule-based routing (no LLM) to select the appropriate agent and forward the message.

route_to_agent(message: str, *, skill_id: Optional[str] = None, tags: Optional[List[str]] = None, context_id: Optional[str] = None) -> str

Parameter Type Default Description
message str Message to route
skill_id Optional[str] None Optional skill ID hint
tags Optional[List[str]] None Optional tags hint
context_id Optional[str] None Optional context for multi-turn

Returns: str — Response from the routed agent

Raises:

  • ValueError — If no router configured or no route matched

Method A2AClientMixin.set_orchestrator

Set an A2A orchestrator for hybrid routing.

The orchestrator combines rule-based routing with LLM-driven decision making for complex scenarios.

set_orchestrator(orchestrator: 'A2AOrchestrator') -> None

Parameter Type Default Description
orchestrator 'A2AOrchestrator' A2AOrchestrator instance

Method A2AClientMixin.get_orchestrator

Get the connected orchestrator.

get_orchestrator() -> Optional['A2AOrchestrator']

Returns: Optional['A2AOrchestrator']

Method A2AClientMixin.orchestrate

Orchestrate a message across multiple agents.

Uses the configured orchestrator which combines rules and LLM-based decision making.

orchestrate(message: str, *, mode: Optional[str] = None, agents: Optional[List[str]] = None, context_id: Optional[str] = None) -> str

Parameter Type Default Description
message str Message to orchestrate
mode Optional[str] None Orchestration mode (rules, llm, hybrid, parallel, sequential)
agents Optional[List[str]] None Optional explicit list of agents
context_id Optional[str] None Optional context for multi-turn

Returns: str — Final response from orchestration

Raises:

  • ValueError — If no orchestrator configured
  • RuntimeError — If orchestration fails

Method A2AClientMixin.fan_out

Send message to multiple agents in parallel.

fan_out(message: str, agents: List[str], **kwargs) -> Dict[str, Union[str, Exception]]

Parameter Type Default Description
message str Message to send
agents List[str] List of agent names
**kwargs {} Additional arguments

Returns: Dict[str, Union[str, Exception]] — Dict mapping agent name to response or exception

Method A2AClientMixin.pipeline

Execute sequential pipeline across agents.

Each agent's output becomes the next agent's input.

pipeline(message: str, agents: List[str], **kwargs) -> str

Parameter Type Default Description
message str Initial message
agents List[str] Ordered list of agent names
**kwargs {} Additional arguments

Returns: str — Final output from last agent

Method A2AClientMixin.add_a2a_agent

Connect to a remote A2A agent.

add_a2a_agent(url: str, *, name: Optional[str] = None, auth_token: Optional[str] = None, api_key: Optional[str] = None, headers: Optional[Dict[str, str]] = None, register_as_tool: bool = True, register_skills_as_tools: bool = False, use_streaming: bool = False, timeout: float = 60.0) -> A2AAgentConnection

Parameter Type Default Description
url str Base URL of the remote agent
name Optional[str] None Optional name override (defaults to agent's name from card)
auth_token Optional[str] None Bearer token for authentication
api_key Optional[str] None API key for authentication
headers Optional[Dict[str, str]] None Additional headers
register_as_tool bool True If True, register the agent as a callable tool
register_skills_as_tools bool False If True, register each skill as a separate tool
use_streaming bool False If True, use streaming for tool calls
timeout float 60.0 Request timeout

Returns: A2AAgentConnection — A2AAgentConnection with the remote agent info

Method A2AClientMixin.remove_a2a_agent

Disconnect from a remote A2A agent.

remove_a2a_agent(name: str) -> None

Parameter Type Default Description
name str Name of the agent to disconnect

Method A2AClientMixin.list_a2a_agents

List connected A2A agent names.

list_a2a_agents() -> List[str]

Returns: List[str]

Method A2AClientMixin.get_a2a_agent

Get a connected A2A agent by name.

get_a2a_agent(name: str) -> Optional[A2AAgentConnection]

Parameter Type Default Description
name str

Returns: Optional[A2AAgentConnection]

Method A2AClientMixin.get_a2a_client

Get the A2A client for a connected agent.

get_a2a_client(name: str) -> Optional[A2AClient]

Parameter Type Default Description
name str

Returns: Optional[A2AClient]

Method A2AClientMixin.ask_remote_agent

Ask a question directly to a remote A2A agent.

ask_remote_agent(agent_name: str, question: str, *, context_id: Optional[str] = None, stream: bool = False) -> str

Parameter Type Default Description
agent_name str Name of the connected agent
question str The question to ask
context_id Optional[str] None Optional context for multi-turn
stream bool False If True, stream the response

Returns: str — The agent's response as text

Raises:

  • ValueError — If agent not connected
  • RuntimeError — If agent returns error

Method A2AClientMixin.invoke_remote_skill

Invoke a specific skill on a remote agent.

invoke_remote_skill(agent_name: str, skill_id: str, params: Optional[Dict[str, Any]] = None, *, context_id: Optional[str] = None) -> Any

Parameter Type Default Description
agent_name str Name of the connected agent
skill_id str ID of the skill to invoke
params Optional[Dict[str, Any]] None Parameters for the skill
context_id Optional[str] None Optional context

Returns: Any — The skill result

Raises:

  • ValueError — If agent not connected

Method A2AClientMixin.shutdown_a2a

Disconnect all A2A connections and cleanup resources.

shutdown_a2a() -> None

Method A2AClientMixin.shutdown

Override shutdown to cleanup A2A connections.

shutdown(**kwargs) -> None

Parameter Type Default Description
**kwargs {}

Alias A2AMeshDiscovery

Re-exported from parrot.a2a.mesh.A2AMeshDiscovery.

Alias A2AOrchestrator

Re-exported from parrot.a2a.orchestrator.A2AOrchestrator.

Alias A2AProxyRouter

Re-exported from parrot.a2a.router.A2AProxyRouter.

Alias A2ARemoteAgentTool

Re-exported from parrot.a2a.client.A2ARemoteAgentTool.

Alias A2ARemoteSkillTool

Re-exported from parrot.a2a.client.A2ARemoteSkillTool.

Alias TaskState

Re-exported from parrot.a2a.models.TaskState.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally