Durable refund agentsTemporal workflows that call four A2A agents · a killed worker loses nothing · a person approves large refunds · money moves once

Temporal 1.32 · Helm 1.8A2A 1.0 · a2a-sdk 1.4MCP gateway (project 1)LLM door + Presidio (project 2)Keycloak · 2 service accountsPostgresReact deskGKE Autopilot

Repo: github.com/bhavishyajain545/gcp-ai-temporal-a2a · rebuild: REBUILD.md · series: 1 MCP gateway · 2 LLM router · 3 n8n hub · 4 incident copilot

Demo (narrated)

Measured on the recorded run

23 s
an auto-approved case end to end: four A2A calls (triage, ledger, policy, comms), the refund, the reply
32 s
from killing the worker that had just moved the money to the case completing on the other worker (8 s heartbeat timeout, retry, then the comms agent); ~20 s in the earlier drill run
1
refund row per case, every time: the retry found the row (PRIMARY KEY case_id) and recorded "already refunded"
0
workflow state held in a worker: the approval wait is a durable timer with reminders, the decision a signal
401 / 403
what an agent answers without a token, and with a token that lacks the orchestrator role; a NetworkPolicy blocks every other pod

How it works

The case, step by step

stepwhat happenswhere
openthe desk starts RefundWorkflow (id refund-<order>-<suffix>) on task queue refunds; the desk keeps no state, it lists workflows (visibility) and reads them with a queryTemporal
triageactivity call_agent sends an A2A message (a data part) to triage-agent; the agent masks personal data with Presidio, then classifies with the auto routeA2A · LLM door
lookupledger-agent runs one read-only SQL through the MCP gateway as service-account-refund-agents; no modelMCP gateway
decidepolicy-agent: rules (not found, already returned, outside 30 days unless damaged, above $5,000 → a person, else approve); the model only writes the explanationA2A · LLM door
a personwait_condition with a timeout: a reminder activity each interval; signal decide from an mcp-admin on the desk; no answer by the deadline means denyTemporal timer + signal
refundissue_refund: heartbeats every 2 s (8 s timeout), inserts refunds(case_id PRIMARY KEY) … ON CONFLICT DO NOTHING; a retry that finds the row returns itworker · Postgres
notifycomms-agent drafts the reply with a <PERSON> placeholder; the workflow fills in the first nameA2A · LLM door

Lessons

symptomcausefix
Temporal Web UI signed in, then rendered nothingthe frontend calls itself through publicClient; via its own ClusterIP Service that hairpin call timed out (20 s) on Autopilotserver.publicClientHostPort: temporal-frontend-headless:7233
an A2A agent answered any callera2a-sdk 1.x declares security schemes in the card but does not check tokensthe agent verifies the Keycloak JWT and the realm role itself; NetworkPolicy as the second lock
ledger failed: could not convert '2.**** **** **** 8889'the gateway masks personal data in results; a long decimal looked like a card numberreturn age_days as an integer
the reply said "order 81.0"A2A data parts are protobuf Structs: every number is a doublecast ids back to int at the edge
a "money moved twice" test that proves nothingkilling the worker before the write only shows a retrythe drill waits for the refund row, then kills the writer; the retry must find it
Built on GKE Autopilot in project bj-ai-platform · source