Agents Agent-to-agent (A2A) Agent cards & errors

Agent cards & errors

Agent cards (discovery)

Agent names are unique within an environment. An agent credential looks up cards in its own environment by default. With an operator credential, use the environment query parameter or an agent UUID to select an instance explicitly. Without a selector, name lookup prefers a production instance, then one with no environment; an unresolved tie returns 409 agent_name_ambiguous.

Every non-retired agent has an A2A 1.0 discovery document. It's generated from the agent's current state, so there's nothing to edit and nothing to drift out of sync:

import os
import httpx

headers = {"Authorization": f"Bearer {os.environ['ANY_TENANT_KEY']}"}

r = httpx.get(
  "https://api.forgebench.ai/v1/agents/invoice-classifier/.well-known/agent-card.json",
  headers=headers,
)
r.raise_for_status()
card = r.json()

# the tenant's whole registry (no name/id — every live agent's card)
r = httpx.get("https://api.forgebench.ai/v1/agents/cards", headers=headers)
r.raise_for_status()
cards = r.json()
  • url points at /v1/agents/{id}/tasks on Forgebench. Discovery does not grant access. Calls require a credential in the same workspace and a live binding.
  • skills include a base chat skill and the agent's live MCP tool bindings. Revoking a tool drops it from the card on the next read, the same way it drops off the allowlist.
  • When the signing key is available, the card carries an EdDSA signature over canonical JSON, using the usage-report signing key. Remove signature before verifying against GET /v1/billing/export/pubkey. If signing fails, the response contains signature.alg: "none"; do not treat it as verified.
  • Cards advertise no task streaming, push notifications, or state-transition history. Push task delivery to a callee webhook is a separate capability.

Standard A2A endpoint

Every agent can also be called by any standard A2A 1.0 client (for example the official a2a-sdk), not only through the Forgebench SDKs. It's the same door: the same binding check, the same task, the same audit row.

To call an agent from a standard client, you need three things:

  1. An approved binding from the calling agent to the agent it calls (grant it on the caller, approve it on the callee).
  2. The calling agent's own key, sent as Authorization: Bearer ….
  3. The per-agent URL: point the client at {your API URL}/a2a/{agent_id}. It resolves the card at /a2a/{agent_id}/.well-known/agent-card.json and sends to the interface the card names.

The official a2a-sdk client fetches that card, verifies its signature against the published keys, and completes ask → answer → artifact on one task.

  • Card: GET /a2a/{agent_id}/.well-known/agent-card.json. A standard A2A 1.0 card: supportedInterfaces points at /a2a/{agent_id} with the JSONRPC binding. Only the agent itself, an agent with an approved binding to it, and console users with read access to agents can read it; anyone else gets 404, the same as for an agent that doesn't exist.
  • Endpoint: POST /a2a/{agent_id}, JSON-RPC 2.0, header A2A-Version: 1.0. Methods: SendMessage, GetTask, CancelTask, ListTasks. Streaming and push-notification configs aren't offered (the card says so).
  • Auth: the calling agent's own key as a Bearer token.
  • Answering a question: when a task is TASK_STATE_INPUT_REQUIRED, send the answer with SendMessage and the task's taskId; the same task continues. An answer is checked like a new call (permission, rate limit, call chain) and recorded in the audit log. If two answers arrive at once, only the first is used; the second gets -32004.
  • Verifying the card: the card carries a detached JWS in signatures over its RFC 8785 form. The public key is at GET /a2a/.well-known/jwks.json (no credential needed; the signature's jku header points there).
import os, uuid
import httpx
from a2a.client import ClientConfig, ClientFactory
from a2a.client.card_resolver import A2ACardResolver
from a2a.types import a2a_pb2 as pb

base = "https://api.forgebench.ai/a2a/" + os.environ["CALLEE_ID"]
http = httpx.AsyncClient(headers={"Authorization": "Bearer " + os.environ["CALLER_AGENT_KEY"]}, timeout=60)

card = await A2ACardResolver(http, base_url=base).get_agent_card()
client = ClientFactory(ClientConfig(httpx_client=http, streaming=False)).create(card)

message = pb.Message(message_id=uuid.uuid4().hex, role=pb.ROLE_USER, parts=[pb.Part(text="Classify invoice 4411")])
async for event in client.send_message(pb.SendMessageRequest(message=message)):
  print(event.task.status.state, event.task.artifacts)

SendMessage waits until the task finishes or asks a question (up to 10 minutes by default); set "configuration": {"returnImmediately": true} to get the task back at once and poll with GetTask (it also doesn't wait for an agent that receives tasks at its own URL). Sending the same message again (same messageId, same content) returns the original task rather than starting a second one, so a send whose response was lost is safe to retry. The same messageId with different content is refused with -32602. Errors come back as JSON-RPC errors: -32001 task not found, -32002 task can't be canceled, -32004 not supported (including a message to a finished task), -32009 unsupported A2A-Version, and -32000 not permitted, which covers every refusal, the same as not_permitted below.

Errors specific to A2A

Beyond the general refusal codes on Errors and refusals, opening, reading, or answering a task has its own shapes:

StatusCauseBody
403not_permitted — returned for every reason a caller can be refused: unknown callee, another workspace's callee, no binding, a revoked binding, a binding pending approval, or a paused/retired callee. All of it collapses to the same response, because telling a caller which of those is true would leak facts about an agent it has no relationship with. The precise reason still lands on the audit log.{"detail":{"code":"not_permitted","message":"not permitted to call that agent"}}
404The task doesn't exist, or exists but you're not its caller or callee.{"detail":"task not found"}
409task_not_working — a reply came in for a task that isn't currently working (already finished, or canceled while a callee was mid-handler).{"detail":{"code":"task_not_working","state":"canceled"}}
413payload_too_large — a task message or a result is over 1 MB.{"detail":{"code":"payload_too_large","size_bytes":5242913,"limit_bytes":1048576}}
429rate_limited — the calling agent opened more than 60 tasks in a minute. Wait for Retry-After seconds.{"detail":{"code":"rate_limited","message":"too many tasks opened; slow down","retry_after_s":23}}

not_permitted covers every cause. To tell them apart during setup, check GET /v1/agents/{agent_id}/agents on the caller, or its Calls tab in the console:

  • no entry for the callee under outbound → no binding was ever granted
  • entry present but showing pending approval → waiting on the callee's owner
  • entry present but shown revoked → the binding was cut

Two more refusals come from the call chain rather than the binding. A task is refused if its callee is already in the chain above it (a loop such as A → B → A), or if the chain already holds 5 tasks. The audit log records them as call_loop and call_depth_exceeded. The chain comes from X-Parent-Call (which serve() handlers pass), or on the A2A endpoint from metadata.forgebench.parentCallId. Calls an SDK serve() handler makes to other agents send it automatically (the task being served is the parent), however many tasks the worker runs at once. A call that sends neither starts a new chain: ForgeBench doesn't guess its parent, so it is never refused as a loop by mistake. For a stock A2A client that doesn't pass its parent, loop and depth checks are therefore best-effort; rate limits and budgets still apply to every call.

Next

Cookie settings

Our Cookie Policy lists every cookie and what it does.