cleandataengineering.aiAgent Harness, drawn simply
You are here: End to end › Router › The direct path

Agent Harness Tutorial · End to end · Zoom level 2

The direct path

When the question is simple and safe, the harness answers it without the model at all: one read from the claims system, poured into wording a person approved in advance.

Router: Directclaim_status, CLM-019002Open: One tool readOne tool readget_claim over MCPzoom in ›Fill a templateapproved wordingOpen: Before-reply checkBefore-reply checkzoom in ›"Claim CLM-019002 is registered. An assessor will look at it and tell you what they need next."104 ms · 0 model calls · $0 · 14 spans
The same check that guards model replies also guards template replies.

The template engine is strict: if a value is missing, it fails rather than printing a blank. So the answer is either exactly right or not sent.

The direct path is the cheapest win in the whole harness. It is about 70 times faster than the loop for the same question, costs nothing, and can never make something up.

Code view: input, process, output, the call stack, the classes

Goes ina Direct route naming a handler and one record id
What happensThe handler reads one row from the claims system with a fixed key and fills in a fixed template, with no model call.
Comes outa Completed reply, or a typed Failed
CALL STACK · START TO FINISHGOES IN → COMES OUT1Open the source: claims_fnol/entrypoint/__init__.py:261Agent._dispatch(decision, ...) # case Direct()claims_fnol/entrypoint/__init__.py:261in: a Direct routeout: (answered, (), (), looked)2Open the source: claims_fnol/entrypoint/direct.py:176answer(decision, identity, run_id, self.tools)claims_fnol/entrypoint/direct.py:176in: Direct, identity, run id, tool clientout: a TurnResult3Open the source: agent_harness/telemetry/__init__.py:314tel.span('agent.direct', agent.handler=...)agent_harness/telemetry/__init__.py:314in: the handler nameout: a span that shows no model call was made4Open the source: claims_fnol/entrypoint/direct.py:136claim_status(decision, identity, run_id, tools)claims_fnol/entrypoint/direct.py:136in: Direct for CLM-… (payout_status/policy_status alike)out: a Completed with the rendered reply5Open the source: claims_fnol/entrypoint/direct.py:88_row(decision, identity, run_id, tools)claims_fnol/entrypoint/direct.py:88in: Direct and tool clientout: row dict, not-found Completed, or Failed6Open the source: agent_harness/contracts/ids.py:107IdempotencyKey(run_id=run_id, step=0, iteration=…agent_harness/contracts/ids.py:107in: the run idout: a fixed key for the single read7Open the source: agent_harness/tools/__init__.py:106GatedTools.list_tools(identity)agent_harness/tools/__init__.py:106in: the customer's identityout: a ToolRegistry filtered by scope8Open the source: agent_harness/contracts/tools.py:354bind_arguments(spec, decision.args)agent_harness/contracts/tools.py:354in: get_claim's spec and {'id': 'CLM-…'}out: arguments named the way the schema wants9Open the source: agent_harness/tools/__init__.py:124GatedTools.call(tool, args, identity, key)agent_harness/tools/__init__.py:124in: 'get_claim', args, identity, keyout: a ToolResult with a structured row10Open the source: claims_fnol/entrypoint/direct.py:126_words(row)claims_fnol/entrypoint/direct.py:126in: the claim rowout: the row plus amount and status in words11Open the source: claims_fnol/entrypoint/direct.py:119_money(value)claims_fnol/entrypoint/direct.py:119in: approved_amountout: a number with comma separators12Open the source: agent_harness/context/__init__.py:41ctx.render(template, **values)agent_harness/context/__init__.py:41in: a CLAIM_REPLIES template and its valuesout: the reply text (StrictUndefined)13Open the source: agent_harness/loop/freshness.py:109freshness.key_of(decision.args)agent_harness/loop/freshness.py:109in: {'id': 'CLM-…'}out: the row key, recorded as looked-at
Read top to bottom: each box is one function call, indented under the function that called it; the dark box is where it starts. Click a box to open its source file.
Dashed boxes are protocols (the ports) or enums; grey boxes are data models; white boxes are classes with behaviour. A dashed arrow means "implements". Click a class to open its source.

How it is done: the real code

Cut from the live repositories each time the site is built, so it always matches what runs.

claims_fnol/entrypoint/direct.py:176The direct path: one read, one approved template
async def answer(
    decision: Direct,
    identity: Identity,
    run_id: RunId,
    tools: ToolClient,
    handlers: Mapping[str, DirectHandler] = HANDLERS,
) -> TurnResult:
    """Dispatch to the handler the router named. No model call, and the trace says so."""
    with tel.span("agent.direct", **{"agent.handler": decision.handler}):
        handler = handlers.get(decision.handler)
        if handler is None:
            return Failed(
                customer_message="I cannot look that up right now.",
                detail=f"no deterministic handler named {decision.handler!r}",
            )
        return await handler(decision, identity, run_id, tools)