cleandataengineering.aiAgent Harness, drawn simply
You are here: End to end › The journey, 78 steps

Agent Harness Tutorial · End to end · Zoom level 1

The end-to-end journey: 78 steps

The same message journey as the map, written out as every single action, one per row: from the chat window opening, through sorting, the queue, the loop, the reply, to what happens out of sight after the turn and before the next release. 78 steps in 14 parts. This table is read live from the Series, so it always matches.

Goes inA customer opening the chat window
What happens78 small actions, each saying where it runs and whether it is built
Comes outA reply, a record, and a better next release
JOURNEY 1 · ARRIVE AND SORTBefore the customer typ…steps 1–5The customer actssteps 6–9Arriving at our serversteps 10–15Sorting the messagesteps 16–20Fixed flow (no agent)steps 21–23JOURNEY 2 · QUEUE AND THE LOOPQueueing the worksteps 24–27Before the loopsteps 28–32Inside the loop: the mo…steps 33–46Inside the loop: a toolsteps 47–53Inside the loop: when t…steps 54–56JOURNEY 3 · REPLY, AND AFTERAfter the loop: the replysteps 57–62When a person is neededsteps 63–66After the turn (out of sight)steps 67–74Before the next releasesteps 75–78
Each part has its own table below, with a link to the page that draws it.

Status says whether each step is built in the claims assistant today, is an Azure feature we configure, or is still to build. The design pages and real flows show what actually ran.

Journey 1 · Arrive and sort

Before the customer types · drawn on One block

#StepRuns inWhat happens, in plain EnglishStatus
1Chat window opensBrowserThe claims app shows the chat window inside the page the customer is already signed in to.Proposed
2Who they areBrowserThe window already knows who the customer is from the portal sign-in.Proposed
3Past messagesBrowser → APIThe window asks for this customer's open conversation and shows the earlier messages.Proposed
4Status cardAPIIf a claim is open, the window shows its current status before the customer asks.Proposed
5Live connectionBrowser ↔ Web PubSub or ChatwootThe window opens a live connection, so a reply can arrive from any server.Proposed

The customer acts · drawn on Front door

#StepRuns inWhat happens, in plain EnglishStatus
6Types or tapsBrowserThe customer types a message, or taps a button such as "Check my claim".
7Message IDBrowserThe window gives the message a unique ID and keeps it if it has to resend.Built
8SendBrowser → Front DoorThe window sends the message, the sign-in token and the ID.Built
9WaitingBrowserThe window shows the message as sent and a "thinking" indicator.Proposed

Arriving at our server · drawn on Front door

#StepRuns inWhat happens, in plain EnglishStatus
10Front DoorAzure Front DoorFront Door filters attacks and passes the request to any healthy server. No sticky sessions.Azure
11ReceivedAPI server (Python)Our Python server receives the message.Built
12Check identityAPI serverIt checks the sign-in token and works out who the customer is and what they may do.Built
13Load conversationAPI → PostgreSQLIt loads the customer's latest conversation.Built
14Duplicate checkAPI → PostgreSQLIt looks up the message ID. A repeat gets the earlier answer instead of a second run.Built
15Shared recordAPI → ChatwootIt adds the message to the customer's conversation in the desk, so staff can see it.Built (Chatwoot adapter)

Sorting the message · drawn on Router

#StepRuns inWhat happens, in plain EnglishStatus
16Rules firstAPI serverButtons, the conversation's state (a form in progress) and simple patterns decide the route when they can.Proposed
17Local classifierAPI serverOtherwise a small classifier inside our server labels the message, with a confidence score.Proposed
18Small modelAPI → gateway → FoundryIf the classifier isn't sure, a small model picks the label.Proposed
19Several asksAPI serverA message with several asks is split into parts, each routed on its own.Proposed
20Route chosenAPI serverThe message goes to a fixed flow, policy search, the agent, a person, or a polite refusal.Built (routes)

Fixed flow (no agent) · drawn on The direct path

#StepRuns inWhat happens, in plain EnglishStatus
21Look upAPI → MCP → claims systemThe flow fetches the facts it needs from the claims system.Built
22Fill the templateAPI serverIt fills an approved reply template. No model writes the answer.Built
23Go to the reply checksAPI serverThe reply joins the same checks as every other reply (stage after the loop).Built

Journey 2 · Queue and the loop

Queueing the work · drawn on L8 · Concurrency & flow

#StepRuns inWhat happens, in plain EnglishStatus
24Into the queueAPI → Service BusAgent and search turns go into a queue with a priority and a deadline.To build
25Picked upWorkerAny free worker takes the turn and holds a lease, so no other worker runs it.To build
26One at a timeWorker → PostgreSQLOnly one turn per conversation runs at once; a second message waits its turn.To build
27Too late?WorkerA turn past its deadline isn't started; the customer is told when to expect a reply.To build

Before the loop · drawn on Context assembly

#StepRuns inWhat happens, in plain EnglishStatus
28Start the runWorkerThe agent starts a run with limits on steps, time and cost.Built
29Allowed toolsWorker → MCPIt lists only the tools this customer may use.Built
30Build what the model seesWorkerIt puts together the instructions, tools, history and new message, always in the same order.Built
31Mark untrusted textWorkerAnything that came from outside, such as document text, is marked as data, not instructions.Built
32Keep it short enoughWorkerIf the history is too long, older exchanges in the middle are trimmed.Built

Inside the loop: the model · drawn on Model call

#StepRuns inWhat happens, in plain EnglishStatus
33Our input checkWorkerOur rules check what's about to go to the model, such as an injection attempt.Built
34Into the gatewayWorker → APIMThe request goes to our AI gateway, never straight to a model.Built (adapter)
35Gateway: sign inAPIMThe gateway signs in to Foundry with its managed identity; the agent holds no model key.Azure
36Gateway: allowed modelsAPIMIt checks this agent may use the model it asked for.Azure
37Gateway: token limitAPIMIt checks the agent's and customer tier's tokens per minute; over the limit gets a polite 429.Azure
38Gateway: edge screenAPIM → Content SafetyOptionally, it screens the request with Content Safety at the edge.Azure (optional)
39Gateway: pick a backendAPIMIt sends the call to the first healthy backend: provisioned first, then pay-as-you-go, then a second region.Azure
40Azure input checkFoundry guardrailAzure screens the input for harm and jailbreaks.Azure
41The model answersFoundry modelThe model reads the request and writes its response.Azure
42Azure output checkFoundry guardrailAzure screens what the model wrote.Azure
43Gateway: count tokensAPIM → Azure MonitorOn the way back, the gateway records tokens by agent, model and tier.Azure
44Gateway: not usedAPIMSemantic cache and full prompt logging stay off: answers are personal, and our own redacted record is the log.
45Count the costWorkerThe call's cost is added to the run's spend. Past the ceiling, the run stops.Built
46Answer or tool?WorkerThe model either gives an answer or asks for a tool.Built

Inside the loop: a tool · drawn on Tool call

#StepRuns inWhat happens, in plain EnglishStatus
47Is it allowed?WorkerBefore a tool runs, our rules check it's permitted and that the customer asked for it.Built
48Needs a person?Worker → DBOSIf the action needs approval, such as a payout, the run pauses and asks an adjuster.To build
49Gateway for toolsAPIM → MCP serverThe gateway checks the token and rate limit before the MCP server sees the call.Azure
50Call the toolWorker → MCP → claims systemThe tool is called with a key that stops a retry from acting twice.Built
51Check the resultWorkerThe result is size-capped, checked for hidden instructions, and marked as data.Built
52Azure tool checkFoundry agent guardrailFor Foundry agents, Azure can also screen tool calls and results.Azure (preview)
53Save progressWorker → PostgreSQLProgress is saved, so a crash resumes from here, not from the start.Built

Inside the loop: when to stop · drawn on When it stops

#StepRuns inWhat happens, in plain EnglishStatus
54LimitsWorkerIf steps, time or cost run out, the loop stops.Built
55No progressWorkerIf the model keeps repeating itself, the loop stops.Built
56RepeatWorkerOtherwise the loop goes back to the model with the new information.Built

Journey 3 · Reply, and after

After the loop: the reply · drawn on 8 · Before the reply

#StepRuns inWhat happens, in plain EnglishStatus
57Our reply rulesWorkerOur rules check the draft reply: no made-up claim numbers, dates, offers or personal data.Built
58Promise checkWorkerAny promise, such as "we'll call you", must be backed by a real task, or the turn escalates.Built
59Safe fallbackWorkerIf a rule blocks, the reply becomes a safe message or a hand-off to a person.Built
60Save togetherWorker → PostgreSQLThe conversation and the reply are saved in one step, so neither exists without the other.Built (state) · outbox to build
61DeliverSender → Web PubSub or ChatwootThe reply is sent to whichever window or channel is open.Proposed
62ShownBrowserThe customer sees the reply. A refreshed or new window loads it too.Proposed

When a person is needed · drawn on DBOS

#StepRuns inWhat happens, in plain EnglishStatus
63Hand-off ticketWorker → ChatwootThe question, what the agent found, and what's missing go to the human desk.To build
64Bot steps backChatwootThe conversation moves to a person, who sees the full history.To build
65WaitsDBOS on PostgreSQLApprovals and hand-offs wait as saved records with timers; any server resumes them.To build
66Decision returnsAPI → DBOSThe adjuster's decision or the desk's resolution resumes the waiting work exactly once.To build

After the turn (out of sight) · drawn on Eval

#StepRuns inWhat happens, in plain EnglishStatus
67TraceWorker → Application InsightsEvery step is recorded, with personal data removed.Built
68CountersWorker → Managed PrometheusCounters update: turns, refusals, steps, cost.Built
69Online rulesScheduled jobA job reads finished turns, runs the same rules again, and stores findings.Built on Langfuse · Azure to build
70Sampled judgesFoundry continuous evaluationA sample of turns is scored by evaluators such as groundedness and task adherence.To adopt
71AlertsManaged PrometheusRules watch windows of turns and alert on spikes, such as refusals or cost.Built
72Daily costScheduled jobThe cost engine explains yesterday's spend and suggests fixes.v0
73CanaryScheduled jobSynthetic customers run real cases on a schedule, to catch breakage early.Built
74DashboardsManaged GrafanaPeople see health, quality, safety and cost for each agent.Built (template)

Before the next release · drawn on Offline

#StepRuns inWhat happens, in plain EnglishStatus
75Golden casesCIThe new version answers the golden cases inside a simulated world (AgentTwin).Built
76Red teamCIAttacks are run against it; their success rate must stay low.Partial
77ReportCIThe eval report compares results with the last release and explains any change.To build
78GateCIIf anything got worse, the release is blocked.Built

Want every detail? The long version is in the Series: the journey overview.