cleandataengineering.aiAgent Harness, drawn simply
You are here: End to end

Agent Harness Tutorial · End to end

One message, end to end

This is the main map. It follows one message from Rohan, from the moment it arrives to the moment the reply goes back. Every box is a door: click it to open a page that draws what is inside that box.

Goes inRohan's message and his sign-in token
What happensFront door, router, then (on the agent path) a loop of context, model and tools, with a check at eight points
Comes outA checked reply, a saved conversation, and a trace we can score
Rohan sends a messageOpen: Front doorFront doorwho is asking? seen it before?zoom in ›Check point 11Open: RouterRouterwhich path is cheapest and safe?zoom in ›Check point 11Open: Direct: template, no modelDirect: template, no modelpaths ›Refuse, or hand to a personTHE LOOP · up to 12 tripswhen does it stop?When the loop stopsagent pathOpen: Context assemblyContext assemblybuild what the model readszoom in ›Open: Pre-model checkPre-model checkzoom in ›Check point 22Open: Model callModel callgpt-oss-120b via APIMzoom in ›Open: Read the answerRead the answerwords, or tool requests?zoom in ›toolsOpen: Pre-tool checkPre-tool checkzoom in ›Check point 44Open: Tool callTool callclaims system, over MCPzoom in ›Check point 55Open: Post-tool checkPost-tool checkzoom in ›Check point 66result added,go round againwordsOpen: Post-model checkPost-model checkzoom in ›Check point 33Open: After-loop rulesAfter-loop ruleszoom in ›Check point 77Open: Before-reply checkBefore-reply checkzoom in ›Check point 88direct answers join hereOpen: Save and settleSave and settlecheckpoint + ledgerzoom in ›Reply to RohanOpen: DBOSDBOSwork that waitsfor a personzoom in ›payout over ₹25,000Open: PostgreSQLPostgreSQLstate and memoryconversationsledger · approvalszoom in ›reads the last checkpointwrites the new oneOpen: Trace, then evalTrace, then evalevery box leavesa record we scorezoom in ›Grey box = a check · dark box = the model · dashed = outside the harness · numbered circles = the 8 check points · every box with a tab opens its own page
Follow the arrows from the top. The dashed rectangle is the loop: it goes round once for every set of tool calls. Click any box, or any numbered circle, to open its page.

Read it in three bands.

  1. Before the loop. The front door proves who is asking. The router then picks a path. Simple, safe questions get a template answer with no model at all. Things the assistant must refuse, or must hand to a person, are dealt with here too.
  2. The loop. Everything else goes round the loop. Each trip: assemble the context, check it, call the model, read the answer. If the model asks for tools, check the request, call the tool, check the result, and go round again. If it answers in words, check the words and leave the loop.
  3. After the loop. A last set of rules and one more check on the reply text, then save the conversation and send the reply.

Three things sit beside the road and are used all the way along: PostgreSQL for state and memory, DBOS for work that has to wait for a person, and the trace that every box writes to.

Two real examples"What's the status of claim CLM-019002?" goes front door, router, Direct, before-reply check, save: 104 ms and no model call. "What is the status of my claim?" has no claim number, so it goes round the loop twice: the first trip asks the tool list_claims, the second writes the answer. 7.1 seconds.
Try it yourselfOpen the Agent Harness Simulator. Type a message as Rohan and watch the same journey as numbered steps on a map: every system it touches, every check that fires, the code, the variables, and the JSON to and from the model. Then break it (switch the agent off, plant an injection, take the model down) and see what reaches App Insights and Prometheus.

Want every detail? The long version is in the Series: the flow in parts, with real spans.

Look inside