Skip to main content

A2A LangChain Adapters

A production-ready Python package for integrating A2A protocol agents into LangChain/LangGraph. Enables stateful conversations, streaming, multi-turn context management, and seamless LLM tool binding with A2A agents.

Build DeepSource DeepSource DeepSource Ruff mypy deptry

🎯 Why This Package?

Integrating A2A protocol agents into LangChain/LangGraph required custom implementations each time. This package standardizes that pattern with a production-ready, well-tested solution. Currently in early release—feedback and contributions welcome.

✨ Features

  • Agent-First Architecture: A2ARunnable preserves full A2A protocol semantics (streaming, task lifecycle, multi-turn conversations)
  • Multi-Transport Support: HTTP (default) and gRPC with auto-detection
  • Task Resubscribe: Reconnect to interrupted streaming tasks for resilience
  • Structured Data: Send/receive JSON-RPC data alongside text
  • File Handling: Upload and download files with URI and bytes patterns
  • Authentication: Bearer tokens, API keys, mTLS, custom headers
  • LLM Tool Binding: Expose agents as LangChain tools for function calling
  • Streaming Support: Real-time Server-Sent Events for long-running tasks
  • Type-Safe: Full mypy strict type checking, async-first design

📦 Installation

Basic (HTTP only)

pip install a2a-langchain-adapters

With gRPC Support

pip install a2a-langchain-adapters[grpc]

🚀 Quick Start

Basic Usage

import asyncio
from a2a_langchain_adapters import A2ARunnable

async def main():
    # Create agent runnable by discovering agent card
    agent = await A2ARunnable.from_agent_url("http://agent.example.com")

    # Send a message and get result
    result = await agent.ainvoke("What is 2 + 2?")
    print(f"Response: {result.text}")

    await agent.close()

asyncio.run(main())

Streaming

async for event in agent.astream("Explain quantum computing"):
    if event.text:
        print(event.text, end="", flush=True)

Multi-Turn Conversations

# Initial message
result = await agent.ainvoke("Tell me about Python")

# Follow-up in same context
agent_conv = agent.with_context(result.context_id)
followup = await agent_conv.ainvoke("What about async?")

Structured Data

# Send JSON data
data = {"action": "analyze", "target": "sales_q4"}
result = await agent.ainvoke(data)
print(result.data)  # Structured response

🛠️ Development

This project uses Just for task automation. All commands are defined in the Justfile.

Setup

just setup

Available Commands

just help              # Show all available commands
just setup             # Setup development environment
just build             # Build the project
just qa                # Run quality assurance (format, lint, type check, dependency check)
just test              # Run tests
just coverage          # Run tests with coverage report

Manual Commands (without Just)

# Setup
uv sync --python=3.13

# Run tests
pytest tests/ -v

# Type checking
mypy src/ --strict

# Linting and formatting
ruff format src/ tests/
ruff check --fix src/ tests/
ruff check --select I --fix src/ tests/

# Dependency checking
deptry .

# Coverage
pytest --cov=src --cov-report=html tests/

☕ Support the Project

If this project helps you, consider supporting its development:

"Buy Me A Coffee"

Your support helps keep the project maintained and growing ❤️

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.

📚 Documentation

Getting Started

External Resources

Release files for a2a-langchain-adapters 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for a2a-langchain-adapters 0.1.0
File Size Uploaded
a2a_langchain_adapters-0.1.0.tar.gz 133.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for a2a-langchain-adapters 0.1.0
File Interpreter ABI Platform
a2a_langchain_adapters-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 158.1 kB

Release files / a2a_langchain_adapters-0.1.0.tar.gz

Download URL a2a_langchain_adapters-0.1.0.tar.gz
Size 133.2 kB
Tags Source
SHA-256 checksum
How to use checksums
804c5ae61996c9f7ed7bc8222e3f2e39d6c9d7453ba8753fbf9408048a980f5f
BLAKE2b-256 checksum
How to use checksums
41986d81ac6329e2c5dbfe4d11bc39a64993c19070f8871f56ebdbce9c5daebe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 11, 2026.

Transparency log

Release files / a2a_langchain_adapters-0.1.0-py3-none-any.whl

Download URL a2a_langchain_adapters-0.1.0-py3-none-any.whl
Size 24.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1d385a6aca33c882980fe2228ed391274f3d0f4e6b70b7ddc9074e39fc9ff19
BLAKE2b-256 checksum
How to use checksums
ab8cb0ccf15d0e9c74f58c981fa6be9ef89895eca2709022c61ec0d81b42013c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page