Skip to main content

Adapters for integrating A2A agents with uAgents framework

Project description

# uAgent A2A Adapter

<!-- [![PyPI version](https://badge.fury.io/py/uagent-a2a-adapter.svg)](https://badge.fury.io/py/uagent-a2a-adapter)
[![Python Support](https://img.shields.io/pypi/pyversions/uagent-a2a-adapter.svg)](https://pypi.org/project/uagent-a2a-adapter/)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) -->

A powerful adapter for integrating A2A (Agent-to-Agent) frameworks with uAgents, enabling seamless communication between different AI agent ecosystems.

## Features

- 🔗 **Seamless Integration**: Connects A2A agents with the uAgents framework.
- 🚀 **Easy Setup**: Simple configuration and deployment process.
- 💬 **Chat Protocol**: Built-in support for agent-to-agent communication.
- 🔄 **Bidirectional Communication**: Supports full-duplex communication between agents.
- 🛡️ **Error Handling**: Robust error handling with fallback mechanisms.
- 📦 **Multiple Frameworks**: Compatible with various AI frameworks (LangChain, CrewAI, MCP).

## Installation

### Basic Installation
```bash
pip install uagent-a2a-adapter

With A2A Support

pip install uagent-a2a-adapter[a2a]

With All Optional Dependencies

pip install uagent-a2a-adapter[all]

Quick Start

Here's a simple example to get started:

from dotenv import load_dotenv
from your_agent_executor import YourAgentExecutor  # Replace with your executor
from uagent_a2a_adapter import A2AAdapter

# Load environment variables
load_dotenv()

def main():
    # Initialize your agent executor
    executor = YourAgentExecutor()
    
    # Create the adapter
    adapter = A2AAdapter(
        agent_executor=executor,
        name="my_a2a_agent",
        description="My A2A agent with uAgents integration",
        port=8082,
        a2a_port=9997,
        mailbox=True,
        seed="my_agent_seed"
    )
    
    print("🚀 Starting A2A Agent...")
    adapter.run()

if __name__ == "__main__":
    main()

Configuration

A2AAdapter Parameters

  • agent_executor: Your A2A agent executor instance.
  • name: Name of your agent.
  • description: Description of your agent's capabilities.
  • port: Port for the uAgent (default: 8000).
  • a2a_port: Port for the A2A server (default: 9999).
  • mailbox: Enable mailbox functionality (default: True).
  • seed: Seed for agent address generation (optional).

Advanced Usage

Using the Register Tool

from uagent_a2a_adapter import A2ARegisterTool

tool = A2ARegisterTool()
result = tool.invoke({
    "agent_executor": your_executor,
    "name": "advanced_agent",
    "description": "An advanced A2A agent",
    "port": 8083,
    "a2a_port": 9998,
    "return_dict": True
})

print(f"Agent created: {result}")

Supported Frameworks

The adapter supports integration with various AI frameworks through optional dependencies:

  • A2A: Core A2A (Agent2Agent Protocol (A2A)) framework support.

Communication Protocol

The adapter uses the uAgents chat protocol for communication:

  1. Message Reception: Receives messages via uAgents chat protocol.
  2. A2A Processing: Forwards messages to A2A agent for processing.
  3. Response Handling: Returns processed responses through uAgents.
  4. Acknowledgments: Automatically handles message acknowledgments.

Error Handling

The adapter includes robust error handling:

  • Connection Failures: Automatically falls back to direct executor calls.
  • Timeout Handling: Configurable timeouts for HTTP requests.
  • Error Messages: Detailed error messages for debugging.
  • Graceful Degradation: Continues operation during partial failures.

Development

Setting up Development Environment

# Clone the repository
git clone https://github.com/gautammanak1/uagent-a2a-adapter.git
cd uagent-a2a-adapter

# Install development dependencies
pip install -e .[dev]

# Run tests
pytest

# Format code
black .
isort .

# Type checking
mypy uagent_a2a_adapter

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=uagent_a2a_adapter

# Run specific test file
pytest tests/test_adapter.py

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

  1. Fork the repository.
  2. Create a feature branch.
  3. Make your changes.
  4. Add tests.
  5. Submit a pull request.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Changelog

See CHANGELOG.md for version history and changes.

Support

Acknowledgments

  • uAgents - The underlying agent framework.
  • A2A - Agent-to-Agent communication protocol.
  • Fetch.ai - For foundational agent technologies.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uagent_a2a_adapter-0.1.1.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uagent_a2a_adapter-0.1.1-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file uagent_a2a_adapter-0.1.1.tar.gz.

File metadata

  • Download URL: uagent_a2a_adapter-0.1.1.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.10

File hashes

Hashes for uagent_a2a_adapter-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d231269fa773b2288a195ae79fc2042ca9150bbffa3b8b3740c3db01ed8c5d90
MD5 77fdb246e03ccb19f6c3a6351350d399
BLAKE2b-256 ebac35f772f5cedf0b10375eec550da0546384ebef75655a0495ceb65cc40850

See more details on using hashes here.

File details

Details for the file uagent_a2a_adapter-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for uagent_a2a_adapter-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 48cc48cde4a2d55032275db8c29431103d305fde8eff2e5b6acff05badc6f0a2
MD5 4f3b2eaf2a22c521d2ee138d30034492
BLAKE2b-256 77cd0765d31c33f70eaa34a0266e8ad44764718a13dbad6f6119210364b8717b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page