Verified on 2026-11-26 against
strands-agents1.63.0,a2a-sdk0.3.26, Python 3.11 and Bedrock inus-east-1. Every number below came from a real run. The scripts and raw output live in https://github.com/pinxiong/strands-in-action/tree/master/usecases/11-boundary. The model isamazon.nova-pro-v1:0.
A local Graph calls a remote expert to save one brief. The write costs one unit
of a quota of three. The call returns — or it does not. In one process,
“did the write happen?” is a question the program answers from its own state.
Across a process boundary, the program is no longer the authority. The reply is
not the authority either. It can be lost, delayed or flattened into a status
that reads end_turn even when the remote side failed.
This post moves one write across a process boundary and watches which guarantees move with it. The orchestrator is a Graph with three nodes: researcher, calculator, writer. The researcher reads a fixed fixture, the calculator sums three invented per-node token counts (1180, 940, 1520 — total 3640, $0.002912 at $0.0008 per 1k), and the writer asks a remote A2A expert to save the brief. The remote expert holds the quota. Seven experiments ask what the caller can know after each kind of crossing: a clean reply, a duplicate retry, a blind retry, a timeout, a readback, an exhausted quota and a killed caller.
The findings are these. A write can land before its reply dies (E3). Blind
retries after that double-spend the quota (E2). The idempotency key is what
makes a retry safe, and it does not cross the boundary on its own (E2, E4,
E5). The caller’s stop reason cannot distinguish success from failure — the
SDK maps TaskState.failed to end_turn. And a killed caller does not roll
back the remote write (E7). The process boundary is not plumbing. It is where
the guarantees change hands.
A receipt is the remote expert’s record that a write happened: an id, the idempotency key, a timestamp. An idempotency key is a caller-supplied token that names one logical write; re-sending it must not create a second write. A readback is a second call that asks the remote what it has, as opposed to trusting the first reply. An unknown state is what the caller is in after a timeout: the write may or may not have landed, and nothing in the exception says which. A quota is a count of writes the remote expert will accept; in these runs it is 2 or 3. Quota exhaustion is not a failure of the request; it is the absence of capacity.
When not to mix#
E6 runs the same three-node task twice: once with all three roles in this process, once with the writer as a remote expert. The fixture, the prompts and the deliverable are identical.
| in-process Graph | cross-process mixed | |
|---|---|---|
| wall clock | 9.19s | 14.64s (+5.45s) |
| failure modes | 1 | 4 |
| where the write lands | in-process ledger | remote receipts file |
| what the caller can trust | the return value | a reply that may be missing |
The boundary adds 5.45 seconds and three failure modes: network timeout into an unknown state, remote quota exhaustion, and a reply lost after the remote write. If you do not need an independent deploy, an independent quota, or a separate failure domain, do not cross the boundary. Keep the write next to the decision. The in-process run finished in 9.19 seconds with one failure mode: process crash, shared fate. That is the right default.
Mix when the write needs a policy the caller cannot be trusted to enforce. In E5 the quota lives on the far side and no amount of caller-side retrying bypasses it. Mix when the writer must outlive the caller (E7). Mix when several orchestrators share one expert. Do not mix to “keep the Graph clean”.
The bench#
Same fixture as the last five posts. Three roles, one brief, one quota-limited write.
# usecases/11-boundary/src/common.py:122-151 -- the remote write
@tool
def save_quota_draft(text: str, key: str) -> str:
"""Save a finished brief under an idempotency key. Costs one quota unit unless the key exists.
Args:
text: The finished brief.
key: Caller-supplied idempotency key for this write.
"""
existing = [r for r in receipts() if r["key"] == key]
if existing:
return json.dumps({"receipt": existing[0]["receipt"], "duplicate": True, "quota": quota_state()})
if not consume_quota():
raise RuntimeError(f"quota exhausted: {quota_state()['used']}/{quota_state()['max']} writes used")
receipt = f"R-{len(receipts()) + 1:03d}"
with RECEIPTS.open("a", encoding="utf-8") as handle:
handle.write(
json.dumps(
{
"receipt": receipt,
"key": key,
"words": len(text.split()),
"text": text[:300],
"pid": os.getpid(),
"t": round(time.time(), 3),
"phase": "saved",
}
)
+ "\n"
)
return json.dumps({"receipt": receipt, "duplicate": False, "quota": quota_state()})The remote expert runs in its own OS process and serves itself over A2A. The caller never imports the server loop. Everything the caller knows about the remote run has to arrive through the wire or through an explicit readback.
# usecases/11-boundary/src/remote_server.py:19-28 -- the remote half
import uvicorn # noqa: E402
from strands.multiagent.a2a.server import A2AServer # noqa: E402
from common import HOST, PORT, remote_agent # noqa: E402
mode = os.environ.get("UC11_REMOTE_MODE", "normal")
port = int(os.environ.get("UC11_PORT") or PORT)
server = A2AServer(agent=remote_agent(mode), host=HOST, port=port)
uvicorn.run(server.to_starlette_app(), host=HOST, port=port, log_level="warning")The SDK’s remote wrapper takes an endpoint and a timeout. The default timeout is 300 seconds; the experiments use 2 or 90.
# strands/agent/a2a_agent.py:44-72 -- verbatim, strands-agents 1.63.0
class A2AAgent(AgentBase):
"""Client wrapper for remote A2A agents."""
def __init__(
self,
endpoint: str,
*,
name: str | None = None,
description: str | None = None,
timeout: int = _DEFAULT_TIMEOUT,
client_config: ClientConfig | None = None,
a2a_client_factory: ClientFactory | None = None,
):
"""Initialize A2A agent.
Args:
endpoint: The base URL of the remote A2A agent.
name: Agent name. If not provided, will be populated from agent card.
description: Agent description. If not provided, will be populated from agent card.
timeout: Timeout for HTTP operations in seconds (defaults to 300).
client_config: A2A ``ClientConfig`` for authentication and transport settings.
The ``httpx_client`` configured here is used for both card discovery and
message sending, enabling authenticated endpoints (SigV4, OAuth, bearer tokens).
When providing an ``httpx_client``, you are responsible for configuring its timeout.
a2a_client_factory: Deprecated. Use ``client_config`` instead.
Raises:
ValueError: If both ``client_config`` and ``a2a_client_factory`` are provided.
"""The caller-side path is one function in the bench. Its return value is exactly
what the caller can know. disk_truth() reads the remote’s files directly —
that is the ground truth for the experiments, not a caller capability.
# usecases/11-boundary/src/common.py:250-268 -- the wire
def call_remote(instruction: str, timeout: int = 90, endpoint: str | None = None) -> dict:
"""Send one instruction to the remote expert. Returns the caller's complete view."""
from strands.agent.a2a_agent import A2AAgent
client = A2AAgent(endpoint=endpoint or BASE, timeout=timeout)
started = time.time()
try:
result = client(instruction)
return {
"outcome": "returned",
"elapsed_s": round(time.time() - started, 2),
"visible": agent_result_summary(result),
}
except Exception as exc: # noqa: BLE001
return {
"outcome": "exception",
"elapsed_s": round(time.time() - started, 2),
"exception": f"{type(exc).__name__}: {exc}",
}E1: the happy path#
A Graph runs researcher → calculator in this process. The writer node calls
consult_remote_writer, which crosses the boundary and asks the remote expert
to save_quota_draft with key uc11-e1. One write, one quota unit.
- caller PID 84789, remote PID 84796 — separate processes
- receipt
R-001, keyuc11-e1, phasesaved - quota
used: 1, max: 3 - Graph tokens 4446 (3896 in, 550 out), 6 model calls (2 per node), 19.89s
The wire view and the disk view agree. The writer node’s text reports
{"receipt": "R-001", "duplicate": false, "quota": {"used": 1, "max": 3}}.
That agreement is the point of comparison for everything below: it is the last
time the two views match for free.
E2: retries and the key#
A retry is not a new decision. It is the same decision arriving twice. The question is whether the second arrival creates a second write.
Two calls with the same key e2-shared:
- first call: receipt
R-001,duplicate: false, quotaused: 1 - second call: receipt
R-001,duplicate: true, quotaused: 1 - one receipt on disk
Two calls with different keys e2-first and e2-second — the blind-retry
pattern, where the caller lost the first reply and re-sends with a fresh key:
- receipts
R-001andR-002, quotaused: 2 - two receipts on disk
12.8 seconds for both phases. The key does not cross the boundary by itself. The caller has to put it in every attempt. That is the whole retention mechanism, and it is also the whole failure mechanism: a retry that forgets its key is a second write.
E3: timeout#
The remote expert writes the receipt first and only then sleeps past the
caller’s timeout. The caller set timeout=2 and asked for slow_save with
seconds=6.
# usecases/11-boundary/src/common.py:154-185 -- write first, reply later
@tool
def slow_save(text: str, key: str, seconds: int = 6) -> str:
"""Write the receipt first, then sleep before replying. Separates the write from the reply.
Args:
text: The finished brief.
key: Caller-supplied idempotency key for this write.
seconds: How long to block after the write before returning.
"""
existing = [r for r in receipts() if r["key"] == key]
if existing:
receipt, duplicate = existing[0]["receipt"], True
else:
if not consume_quota():
raise RuntimeError(f"quota exhausted: {quota_state()['used']}/{quota_state()['max']} writes used")
receipt, duplicate = f"R-{len(receipts()) + 1:03d}", False
with RECEIPTS.open("a", encoding="utf-8") as handle:
handle.write(
json.dumps(
{
"receipt": receipt,
"key": key,
"words": len(text.split()),
"pid": os.getpid(),
"t": round(time.time(), 3),
"phase": "written_before_reply",
}
)
+ "\n"
)
time.sleep(seconds)
return json.dumps({"receipt": receipt, "duplicate": duplicate, "quota": quota_state()})What the caller saw: A2AClientTimeoutError: Timeout Error: Client Request timed out. What was on disk at the moment the exception was raised: receipt
R-001, key e3, phase written_before_reply. The write had already landed.
The quota unit was already spent.
This is the unknown state. Not a failure — a failure would mean the write did not happen. Not a success — the caller has no receipt id. The exception carries no information about which one it is. In E5’s phrasing, the caller cannot tell “never happened” from “happened but the reply is gone”. The only correct posture is to treat the state as unknown and go look (E4).
E4: readback and the same key#
Continue the E3 situation. The caller does not guess. It re-sends the same
idempotency key e4 and asks the remote to read back what it has.
- readback via
quota_status: quotaused: 1, receiptR-001present - same-key retry:
{"receipt": "R-001", "duplicate": true, "quota": {"used": 1, "max": 3}} - still one receipt on disk, still one quota unit
26.06 seconds end to end. The readback converts “unknown” into “known” before any decision is made. The same-key retry is then safe by construction: the remote recognises the key and returns the existing receipt. Without the key, the retry in E2’s second phase is what happens — a second write and a second quota unit.
E5: quota lives on the far side#
Set the quota to 2. Two writes with different keys fill it. The third write comes back as text:
Error: RuntimeError - quota exhausted: 2/2 writes usedThe call’s outcome is returned. The stop reason is end_turn. A caller
checking only those two fields sees a successful call. This is the swallowed
failure from the earlier posts, now with a network in front of it.
Then the key shows its second job. Re-sending the first write’s key e5-first
after exhaustion returns {"receipt": "R-001", "duplicate": true, "quota": {"used": 2, "max": 2}} — not a quota error. A retry after an unknown state
never has to compete for capacity, because the remote recognises the key
before it looks at the quota. Two receipts on disk, quota 2/2, 11.73
seconds.
The quota is enforced in the remote process. No caller-side retry loop can bypass it. That is the property the boundary buys, and it is why the quota belongs on the far side in the first place.
The caller cannot see failure#
The A2A adapter maps task states to stop reasons before the caller sees anything:
# strands/multiagent/a2a/_converters.py:16-24 -- verbatim, strands-agents 1.63.0
# Mapping from A2A TaskState to Strands stop_reason
_STATE_TO_STOP_REASON: dict[TaskState, StopReason] = {
TaskState.completed: "end_turn",
TaskState.failed: "end_turn",
TaskState.canceled: "end_turn",
TaskState.rejected: "end_turn",
TaskState.input_required: "interrupt",
TaskState.auth_required: "interrupt",
}TaskState.failed becomes end_turn. So does completed, canceled and
rejected. After the crossing, the caller’s stop reason is end_turn for
every finished remote task, successful or not. The failure, if it is visible
at all, is visible only as text.
That leaves the caller with three observable states, and none of them is “failed”:
outcome: returned,stop_reason: end_turn— may be a success (E1) or a swallowed failure (E5). Read the text or read the receipt.outcome: exception— unknown. The write may have landed (E3). Read back.- Nothing distinguishes these two by status field. The evidence does.
This is why the experiments assert on receipts and quota, not on stop reasons. Operation-level evidence — how many receipts, which keys, what quota — is checkable. Status fields across the boundary are not.
E7: the write outlives the caller#
A child process starts a remote write whose receipt lands immediately and whose reply is delayed. The parent kills the child mid-call. The remote expert does not notice and does not care. Its write is already on disk.
- child killed with SIGKILL after 3 seconds
- receipt
R-001, keye7, phasewritten_before_reply— on disk anyway - quota
used: 1 - a new caller reads the receipt back through
quota_status
15.21 seconds. The write’s lifecycle is not the caller’s lifecycle. In one process they share a fate: kill the process and the in-flight write dies with it, and you cannot even tell which side of the write the kill landed on without external storage. Across the boundary, the write’s completion is independent, and the readback is how the next caller finds out.
This is the capability a single paradigm does not give you in the same shape: an independent authority for the write that survives the orchestrator’s death. The cost is everything in the table above.
What the boundary changed#
| guarantee | in one process | across the boundary |
|---|---|---|
| did the write happen? | read the variable | read back a receipt or don’t know |
| retry safety | re-run the function | same idempotency key, or a second write |
| timeout meaning | n/a | unknown state, not failure |
| quota enforcement | caller code, resettable | remote process, not bypassable |
| failure signal | the exception type | flattened to end_turn; text only |
| caller death | shared fate with the write | the write survives (E7) |
Every row except the last is a guarantee that got weaker or got more expensive. The last row is the one that got stronger. That is the trade.
The fencing lesson carries over#
In the reservations post, a worker reserved quota, crashed, and the expired lease returned the capacity — while the side effect had already happened. The conclusion was that only an authoritative terminal state or destination fencing can safely release reserved capacity.
The same rule applies here with the words changed. After an unknown state (E3), a caller must not “release” the quota unit because the call threw a timeout. The write may have landed, and in E3 it did. Releasing would make the capacity lie. The only safe release is one backed by a readback that says the receipt is absent. Until then, the quota unit is spent.
# usecases/11-boundary/src/common.py:271-273 -- the only sane post-timeout move
def readback(endpoint: str | None = None, timeout: int = 30) -> dict:
"""Ask the remote, through the wire, to report its own quota and receipts."""
return call_remote("Call quota_status exactly once and report the result verbatim.", timeout=timeout, endpoint=endpoint)What this experiment does not cover#
This experiment does not cover authentication, SigV4, OAuth or bearer tokens.
The A2AAgent docstring quoted above names those schemes; none is configured
here. It does not cover multi-tenant context isolation, streaming artifact
schemas, provider-side ledger reconciliation or answer quality and cost per
useful result. It does not cover a genuine network partition: E3 is one
deliberate six-second sleep behind a two-second client timeout, not a lost
link. It does not cover concurrent callers racing the same key. E2 sends its
two calls in sequence, so the race UC05 measured with real clocks is out of
scope here. It does not cover an A2AAgent mounted as a Graph node; the
writer here calls a helper that opens its own client. It does not cover a
receipt store that is itself unavailable. Every readback in E4 and E7 assumes
the remote files are readable, and I set no retry bound before giving up. The
five findings this post reports are not in this list: the write landing before
its reply dies, blind retries spending quota twice, the key that does not
cross on its own, the stop reason that cannot name failure and the write that
outlives a killed caller. E2 through E7 measure them.
Takeaways#
- Do not cross the boundary unless the write needs an independent quota, an independent failure domain, or an independent lifetime. E6’s in-process run is 5.45 seconds faster and has one failure mode instead of four.
- Give every write an idempotency key and send it on every attempt. The key is the retry policy. E2: same key, one receipt; fresh key per attempt, two.
- After a timeout, the state is unknown, not failed. Read back (E4), then retry with the same key. Do not release quota without an authoritative readback (the fencing rule).
- Do not trust
stop_reasonacross the boundary.TaskState.failedmaps toend_turn. Assert on receipts and quota counts; those are operation-level and checkable. - The write can outlive the caller (E7). If that matters, the boundary earns its cost. If it does not, stay in one process.
Try it yourself#
git clone https://github.com/pinxiong/strands-in-action.git
cd strands-in-action/usecases/11-boundary
python3 -m venv .venv && source .venv/bin/activate
pip install strands-agents==1.63.0 a2a-sdk==0.3.26 fastapi uvicorn
export AWS_REGION=us-east-1
.venv/bin/python src/e1_happy.py
.venv/bin/python src/e2_retry_keys.py
.venv/bin/python src/e3_timeout_write_landed.py
.venv/bin/python src/e4_readback_recovery.py
.venv/bin/python src/e5_quota_exhaustion.py
.venv/bin/python src/e6_when_not_to_mix.py
.venv/bin/python src/e7_caller_crash.pyEach script starts its own remote server process on ports 9254–9260, runs
against Bedrock, writes evidence/*.json and evidence/*.txt and asserts
the operation-level claims above. The raw output of the runs behind this post
is already in evidence/.
Next: when an orchestrator’s own state and a remote expert’s state disagree, which one does the downstream gate believe — and what does it need to see to decide?