Integrate A2A protocol agents into LangChain/LangGraph applications
Project description
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.
🎯 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:
A2ARunnablepreserves 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:
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
- 📖 Documentation Hub - Start here for a complete overview
- 🚀 Getting Started Guide - Installation and your first query
- 💡 Usage Guide - Streaming, multi-turn conversations, file handling, and best practices
- ⚙️ Configuration Reference - Authentication, transport, security, and advanced options
External Resources
- A2A Protocol Spec - Complete protocol specification
- LangChain Docs - LangChain integration reference
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file a2a_langchain_adapters-0.0.0.tar.gz.
File metadata
- Download URL: a2a_langchain_adapters-0.0.0.tar.gz
- Upload date:
- Size: 133.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b80e3fe096bf2b046375a4ecedd6455ed2520a105dd31c3a69f34502b2f82d92
|
|
| MD5 |
c9a21abb7b4de418049c896f4656bfd9
|
|
| BLAKE2b-256 |
cd5036855235a06a4c505854151bc9eac09593bdd5a386b25e96e6392c53b0c6
|
Provenance
The following attestation bundles were made for a2a_langchain_adapters-0.0.0.tar.gz:
Publisher:
release.yml on janrauchfuss/a2a-langchain-adapters
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
a2a_langchain_adapters-0.0.0.tar.gz -
Subject digest:
b80e3fe096bf2b046375a4ecedd6455ed2520a105dd31c3a69f34502b2f82d92 - Sigstore transparency entry: 937826889
- Sigstore integration time:
-
Permalink:
janrauchfuss/a2a-langchain-adapters@1f288d74dfe67dc653d96e677770f980d63ecefe -
Branch / Tag:
refs/heads/main - Owner: https://github.com/janrauchfuss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1f288d74dfe67dc653d96e677770f980d63ecefe -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file a2a_langchain_adapters-0.0.0-py3-none-any.whl.
File metadata
- Download URL: a2a_langchain_adapters-0.0.0-py3-none-any.whl
- Upload date:
- Size: 24.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4834da9d42a1b123043924090661407f5e8b748a4957bb8e71a2f8054ceeeb94
|
|
| MD5 |
92568849ddcdb7dd243c87d5b0dd3f66
|
|
| BLAKE2b-256 |
b1f2cdc0195a64372aeb1e19945970ad1e2809deb2a53b6a9d7be3dc72b2e984
|
Provenance
The following attestation bundles were made for a2a_langchain_adapters-0.0.0-py3-none-any.whl:
Publisher:
release.yml on janrauchfuss/a2a-langchain-adapters
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
a2a_langchain_adapters-0.0.0-py3-none-any.whl -
Subject digest:
4834da9d42a1b123043924090661407f5e8b748a4957bb8e71a2f8054ceeeb94 - Sigstore transparency entry: 937826944
- Sigstore integration time:
-
Permalink:
janrauchfuss/a2a-langchain-adapters@1f288d74dfe67dc653d96e677770f980d63ecefe -
Branch / Tag:
refs/heads/main - Owner: https://github.com/janrauchfuss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1f288d74dfe67dc653d96e677770f980d63ecefe -
Trigger Event:
workflow_dispatch
-
Statement type: