Skip to main content

langchain-remote-a2a-agent

PyPI License Python

LangChain-native equivalent of Google ADK's RemoteA2aAgent. Wraps any Agent2Agent (A2A) protocol server as a LangChain Runnable, so a remote agent can be .invoke()d, .astream()ed, dropped into a create_agent/LangGraph pipeline as a node, or exposed to another agent as a callable tool via .as_tool() — the same interface you'd use for any local LangChain component.

This is useful when the agent doing the actual work runs as a separate service (different language, different team, different deployment) and you want to compose it into a LangChain-orchestrated system without hand-rolling the A2A JSON-RPC/SSE client plumbing yourself.

Install

pip install langchain-remote-a2a-agent

Requires Python 3.11+. Ships a py.typed marker — type checkers (mypy, Pyright) and IDE autocomplete/hover (VS Code + Pylance) pick up the inline type hints and docstrings automatically once installed.

Quickstart

from langchain_remote_a2a_agent import RemoteAgent

research = RemoteAgent(
    name="research",
    description="Research agent",
    agent_card_url="http://localhost:8001/.well-known/agent-card.json",
)

result = research.invoke("What is the boiling point of nitrogen?")
print(result["messages"][-1].content)

Multi-turn conversations

Pass a thread_id to resume the same server-side A2A context across calls:

from langchain_core.runnables import RunnableConfig

config = RunnableConfig(configurable={"thread_id": "user-42"})

result1 = research.invoke("Tell me about black holes.", config)
result2 = research.invoke("How do they emit Hawking radiation?", config)

Streaming

async for chunk in research.astream("Explain quantum entanglement."):
    if chunk.get("messages"):
        msg = chunk["messages"][-1]
        if reasoning := msg.additional_kwargs.get("reasoning_content"):
            print(f"[reasoning] {reasoning}")
        elif msg.content:
            print(msg.content, end="", flush=True)

As a tool inside a LangChain agent

from langchain.agents import create_agent

supervisor = create_agent(
    model="openai:gpt-5",
    tools=[research.as_tool()],
)

More examples

Nine complete, runnable examples — synchronous/async invocation, multi-turn state, streaming with reasoning traces, create_agent integration, LangGraph node usage, concurrent batching, bearer-token auth, and agent-card inspection — live in langchain_remote_a2a_agent/examples.py. They're also directly importable for reference:

from langchain_remote_a2a_agent import examples

API surface

Export What it is
RemoteAgent The main Runnable — wraps a remote A2A agent.
RemoteAgent.as_tool() Returns a BaseTool for use inside another agent's tool list.
RemoteAgent.reset_thread() Clears the stored context_id for a thread_id, starting a fresh server-side conversation.
RemoteAgent.thread_state() JSON-serialisable snapshot of a thread's tracked state.
RemoteAgent.aget_agent_card() Fetch (or return cached) the remote agent's Agent Card.
RemoteAgent.aget_extended_agent_card() Fetch the remote agent's Extended Agent Card.
ThreadState, ConversationStateStore The conversation-state tracking types, exposed for custom store implementations.
RemoteAgentError and subclasses CardResolutionError, A2AProtocolError, A2ATimeoutError, A2AAuthError, A2AStreamError, InputNormalisationError — catch these individually or RemoteAgentError for all of them.

Agent Card Inspection

You can inspect the capabilities, skills, security requirements, and metadata of the remote agent by fetching its Agent Card:

Public Agent Card

The Public Agent Card is resolved from the agent card URL when the agent is first initialized:

# Fetch (or return cached) the public agent card
card = await research.aget_agent_card()

print("Agent name:", card.name)
print("Description:", card.description)
print("Skills:", card.skills)

Extended Agent Card

If the remote agent supports an extended card (carrying additional metadata or developer-defined parameters that might require auth/permissions), you can fetch it using aget_extended_agent_card():

# Fetch the extended agent card from the remote server
extended_card = await research.aget_extended_agent_card()

print("Developer info:", extended_card.provider.organization)
print("Extended capabilities:", extended_card.capabilities)

Github Repo

LangChain Remote A2A Agent

Tests

# Run against a live agent
pytest tests/test_integration.py -v --agent-url http://localhost:8001/.well-known/agent-card.json

# With auth token for extended card
pytest tests/test_integration.py -v \
  --agent-url http://localhost:8001/.well-known/agent-card.json \
  --auth-token "Bearer sk-..."

# Custom test query
pytest tests/test_integration.py -v \
  --agent-url http://localhost:8001/.well-known/agent-card.json \
  --test-query "Summarize quantum computing"

License

Apache License 2.0 — see LICENSE.

Metadata

Release files for langchain-remote-a2a-agent 1.0.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 langchain-remote-a2a-agent 1.0.0
File Size Uploaded
langchain_remote_a2a_agent-1.0.0.tar.gz 35.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-remote-a2a-agent 1.0.0
File Interpreter ABI Platform
langchain_remote_a2a_agent-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 70.2 kB

Release files / langchain_remote_a2a_agent-1.0.0.tar.gz

Download URL langchain_remote_a2a_agent-1.0.0.tar.gz
Size 35.7 kB
Tags Source
SHA-256 checksum
How to use checksums
921844f825d074e335fcc510167e55c3e8a2ed3bd5f736e191ab3281c3e8db36
BLAKE2b-256 checksum
How to use checksums
f4ea7d689a462f7073f549bb68e54c80437bffd8cf8f8fb90db79612974238dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / langchain_remote_a2a_agent-1.0.0-py3-none-any.whl

Download URL langchain_remote_a2a_agent-1.0.0-py3-none-any.whl
Size 34.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8ffcc1350243e444f8050731b85655c7ef8f3ec61c7335d831b3dfff2be0c1c1
BLAKE2b-256 checksum
How to use checksums
be36756bc72ca55647f916b8a9ed9a9e1b915b5e0deaf47066c3d54d3b856da6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.2.1

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