Skip to main content

Adapters for integrating A2A agents with uAgents framework

Project description

uAgent A2A Adapter

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.

Installation

Basic Installation

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.2.tar.gz (17.8 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.2-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: uagent_a2a_adapter-0.1.2.tar.gz
  • Upload date:
  • Size: 17.8 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.2.tar.gz
Algorithm Hash digest
SHA256 88297e47b0f846f249fd8c3cec76f8ec2557d90acd59bf972d48791df15dd97d
MD5 a3bd81dbfc428a8285c7643c4cb388dc
BLAKE2b-256 e43cd48ffc2b143a53cc5703c3d32d012bb026b47ca1e88098dca69a2dec7079

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for uagent_a2a_adapter-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1591f190c6ca7ae6eb01acf65f74b22dd5fa65b60103178dcf0ba9a3bf9634d6
MD5 bc869824f371dadbfdfbbd553ebbe65f
BLAKE2b-256 d397749e380229c3289ad11ba7b47dc5a96d76cf23e5aedc16a8c839b0e18c2e

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