Skip to main content
Agentgateway supports the Agent2Agent (A2A) protocol, enabling it to proxy traffic between AI agents. Enabling A2A mode adds protocol-level telemetry, agent card rewriting, and A2A-specific processing to any route.

How A2A proxying works

Unlike MCP, an A2A backend is a plain HTTP host — any A2A-compatible agent server. The a2a policy on a route tells Agentgateway to treat traffic on that route as A2A and process it accordingly. When A2A mode is active, the gateway:
  • Rewrites the agent card at /.well-known/agent.json so the url field points back to the gateway, preventing clients from bypassing it on subsequent requests
  • Extracts the A2A method (message/send, message/stream, etc.) from each request and adds it to structured logs as a2a.method
  • Applies all standard gateway policies (CORS, authentication, authorization, rate limiting) to A2A traffic

Configuration

Here is the complete configuration from examples/a2a/config.yaml:
config.yaml
The key addition compared to a plain HTTP proxy is a2a: {} in the route’s policies block. The backend is a host reference — the address of your upstream A2A agent server.

Running the example

1

Clone and start the sample A2A agent

The A2A samples project provides a reference agent implementation you can use for testing.
This starts the agent on localhost:9999.
2

Start Agentgateway

In a separate terminal, run the gateway with the A2A example config:
The gateway listens on port 3000 and proxies A2A traffic to localhost:9999.
3

Connect a client

Run the sample CLI client and point it at the gateway:
Send a few messages through the CLI to generate traffic through the gateway.

Agent card rewriting

The A2A protocol uses an agent card at /.well-known/agent.json to advertise an agent’s capabilities and endpoint URL. When Agentgateway proxies A2A traffic, it rewrites the url field in the agent card to point back to the gateway. This ensures that clients always route future requests through the gateway, rather than connecting directly to the upstream agent. For example, fetch the agent card through the gateway:
The url has been rewritten from localhost:9999 to localhost:3000 — the gateway’s address.

A2A telemetry

When A2A mode is active, Agentgateway adds the a2a.method field to structured access logs. This captures the A2A JSON-RPC method for each request, making it easy to filter and analyze agent communication patterns. Example log line from a streaming message exchange:
The a2a.method field identifies the specific A2A operation — in this case, message/stream.
Enable JSON log format (config.logging.format: json) when running in production to make log aggregation and querying easier with tools like Loki, Elasticsearch, or CloudWatch.

Policy support

All standard Agentgateway route policies apply to A2A routes. You can layer authentication, authorization, and rate limiting on top of A2A traffic:
See the Authentication guide and Authorization guide for details on securing A2A routes.