Files
Eduard van Valkenburg 5534198142 Python: add agent-framework-hosting-a2a channel (#6306)
* feat(python): add agent-framework-hosting-a2a channel

Add a hosting channel that exposes the host target (agent or workflow)
as a peer agent over the Agent-to-Agent (A2A) protocol (JSON-RPC plus a
served agent card). Requests are handled by a host-routed
HostAgentExecutor that drives the host pipeline (ChannelContext.run/
run_stream) instead of wrapping the target directly, so sessions,
linking, and run/response hooks apply. Maps the A2A conversation/context
id to a ChannelSession isolation key and the caller to a ChannelIdentity;
streaming emits incremental task artifacts.

Includes tests, README, and workspace registration.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Address A2A hosting channel review feedback

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-12 12:20:54 +02:00

37 lines
1.4 KiB
Markdown

# agent-framework-hosting-a2a
Agent-to-Agent (A2A) protocol channel for `agent-framework-hosting`.
Exposes the hosted target (an `Agent` or a `Workflow`) as an A2A peer agent: it
publishes an agent card and JSON-RPC routes and drives every request through the
host pipeline, so host sessions, request metadata, and run/response hooks all
apply.
```python
from agent_framework.openai import OpenAIChatClient
from agent_framework_hosting import AgentFrameworkHost
from agent_framework_hosting_a2a import A2AChannel
agent = OpenAIChatClient().as_agent(name="Assistant")
host = AgentFrameworkHost(
target=agent,
channels=[A2AChannel(url="https://my-host.example.com/")],
)
host.serve(port=8000)
```
By default the channel mounts at the app root so the well-known agent card is
reachable at `/.well-known/agent-card.json`, with the JSON-RPC endpoint at `/`.
The A2A `context_id` maps onto the host session (caller-supplied session family).
A default agent card is derived from the target's name and description; pass a
fully-specified `agent_card` to override it. To advertise additional protocol
bindings in the generated card, pass `supported_interfaces`.
> **Note:** Task state is held in an in-memory A2A task store for this version; it
> is independent of the host's session storage and is not persisted across
> restarts.
The base host plumbing lives in
[`agent-framework-hosting`](https://pypi.org/project/agent-framework-hosting/).