Skip to Content
These docs describe donkey-kit v0.3.0. Release notes
Local simulatorA2A faults & replay

Live

A2A faults & replay

The local simulator replays model-route refusals. This page covers its A2A counterparts: refusing an outbound call made through donkey.a2a with donkey.simulate_a2a(), and replaying captured A2A ingress refusals. For the policies these captures come from, see A2A gateway policies.

Outbound A2A fault injection

donkey.simulate_a2a() is the A2A counterpart of simulate() and simulate_mcp(). It makes an agent you call through donkey.a2a get a captured gateway refusal, with no gateway and no Exchange. Like donkey.a2a, it is provisional.

import pytest from a2a.types import Message, Part, Role, SendMessageRequest from donkey_kit import Donkey, ToolInvocationError request = SendMessageRequest( message=Message(message_id="m1", role=Role.ROLE_USER, parts=[Part(text="Email a@b.c")]) ) async def test_delegation_handles_a_pii_block(): async with Donkey.from_env(allow_a2a_sdk_telemetry=True) as donkey: with donkey.simulate_a2a("pii-send", agents=["acme/triage-agent/1.0.0"]): with pytest.raises(ToolInvocationError): await donkey.a2a.send("acme/triage-agent/1.0.0", request) # times=1: the next call gets a simulated reply await donkey.a2a.send("acme/triage-agent/1.0.0", request)
  • Inside the block, the refs in agents resolve without Exchange: no governance read and no endpoint lookup. Any other ref raises RegistryError. The agent card and the replies are served offline, through the official SDK’s own JSON-RPC transports.
  • A -send capture refuses send() only, and a -stream capture refuses stream() only. Every other call gets one text part, "simulated reply", or what reply(text) returns.
  • Every injected response carries x-donkey-simulator: true. Blocks do not nest, and after the block the refs resolve through Exchange again.
  • The outbound A2A SDK tracing gate applies offline too. With opentelemetry installed (the [otel] and [all] extras) and OTEL_INSTRUMENTATION_A2A_SDK_ENABLED unset, the first call raises ConfigError instead of the refusal. Set the variable to false before importing a2a (for example in conftest.py), or build the client with Donkey.from_env(allow_a2a_sdk_telemetry=True).
captureversion="1.0"version="0.3"Raised error
pii-send, pii-streamyespii-send onlyToolInvocationError
azure-block-send, azure-block-streamyesnoContentSafetyBlocked
rate-send, rate-streamyesrate-send onlyTokenBudgetExceeded

The raised error is whatever the existing classification gives each packaged Omni Gateway capture, the same bytes listed in A2A gateway policies. The rate-limit captures have no body, so the error carries headers only. This covers agents you call. For an agent you serve, use the ingress replay below.

A2A ingress replay

See A2A gateway policies for the version-specific capture inventory. Local replay verifies handling, not gateway enforcement.

donkey dev wraps your served agent rather than the model routes above. It shares the fixture loader and scenario triggers, but selects captured A2A refusals with --protocol-version: 1.0 by default, or 0.3.0. This is separate from --agent-version, the card’s application release version. The supported scenario/version/method matrix is:

ProtocolCall methodpii_blockrequest_limitinjection
1.0 (default)SendMessageCaptured send refusalCaptured send refusalCaptured Azure send block
1.0SendStreamingMessageCaptured stream refusalCaptured stream refusalCaptured Azure stream block
0.3.0message/sendCaptured legacy send refusalCaptured legacy send refusalUnsupported at construction/startup
0.3.0message/streamLocal HTTP 400 with any scenariosLocal HTTP 400 with any scenariosUnsupported at construction/startup

v0.3 streaming with configured scenarios fails before any rule advances, even if the stream would not trigger a rejection. Without scenarios, message/stream passes through with the agent’s own bytes; this is not a promise that the wrapped agent supports streaming. build_app() advertises streaming: false.

Known call methods from the wrong version and explicit mismatched A2A-Version headers on calls also return local plain-text HTTP 400, even without scenarios. Configuration accepts exactly 1.0 or 0.3.0, but header matching follows the official SDK’s version normalization and compares only the major version: 1.0.0 matches selected 1.0, and 0.3.1 matches selected 0.3.0. Other parseable versions with the same major also match; malformed versions or a different major do not. An absent header retains replay behavior; the SDK validates passing calls. These local errors carry x-donkey-simulator: true, not a fabricated gateway refusal or JSON-RPC policy error. Unknown methods, malformed JSON, card reads and task reads/cancels pass to the agent’s SDK routes.

Each supported cell uses its matching capture, with these DDK outcomes:

ScenarioA2A ingress responseExisting classification
injection (v1 only)Azure prompt-shield 403, ErrorInfo and x-flex-azure-guardrails-*ContentSafetyBlocked
pii_block403 with synthetic findings: v1 ambiguous ErrorInfo, v0.3 string error.dataToolInvocationError, not PIIDetected
request_limitBare 429 with captured x-token-*, no retry-afterTokenBudgetExceeded

On ingress, request_limit counts requests as a replay trigger, not a token policy implementation. The configured limit/window decides when the capture is returned; captured header values stay 1 limit, 1 remaining and 60000 ms to reset, even if your local counter or clock differs. Passing calls gain no rate headers. Test-only accepted v0.3 and v1 send captures record individual windows, not a local accounting or passing-call replay contract. The donkey mock request counter and headers described above are unchanged.

The response ID stays captured (v1 string "1393", v0.3 PII numeric 1393), not your incoming request ID. Bodies are not reserialized; only transport framing and the existing safe-header filter differ from the capture. Streaming refusals are HTTP JSON or empty responses, not SSE events. Other calls and passing streams retain the agent’s own bytes when supported, with the honesty header added. budget and ciba are not ingress scenarios. No outbound A2A or authorization-code simulation is provided.

The tested stock v1 a2a-sdk 1.2.2 JSON-RPC transport generates UUID request IDs, then raises A2AClientError caused by httpx.HTTPStatusError for these send and stream refusals before RPC decoding or ID checks. This is HTTP refusal evidence, not a guarantee of successful correlation for other clients. The table lists DDK classifications; the stock SDK does not raise those DDK types.

Next steps

Last updated on