Skip to main content
A2AClient enables PraisonAI applications to discover and interact with remote A2A agents through an async HTTP interface. The user asks the agent to reach a remote A2A server; the client discovers capabilities and exchanges messages over HTTP.

Quick Start

1

Simple Usage

Connect to an A2A server and send a message:
2

With Authentication

Use bearer token authentication:

How It Works


Configuration Options


Discovery Methods

Get Agent Card

Fetch basic agent information from /.well-known/agent.json:

Get Extended Card

Fetch detailed agent information (requires authentication):

Message Methods

Send Message

Send a text message and get the complete task result:
Multi-turn conversations with context:

Streaming Messages

Send a message and receive real-time Server-Sent Events:

Task Management

Get Task Details

List Tasks

Cancel Task


Context Manager Pattern

Recommended approach with automatic session cleanup:
Manual management when needed:

Agent-to-Agent Communication

Complete example showing agent-to-agent delegation:

Error Handling

Handle common HTTP and connection errors:

Common Patterns

Always fetch the agent card first to understand capabilities before sending messages.
Maintain conversation context across multiple message exchanges.
Monitor long-running tasks with periodic status checks.
Process multiple tasks concurrently using asyncio.

Best Practices

Always use the context manager pattern to ensure proper session cleanup and avoid connection leaks.
Implement retry logic for transient network errors and timeouts.
Store auth tokens securely and never expose them in logs or error messages.
Handle streaming events gracefully with proper error handling and backpressure.

A2A Protocol

Setup A2A servers and protocol basics

Multi-Agent Patterns

Agent orchestration and communication patterns