cleandataengineering.aiAgent Harness, drawn simply
You are here: End to end › Checks › 4 · Before the tool › freshness

Agent Harness Tutorial · End to end · Zoom level 3

How we take care of it: freshness

freshness catches an irreversible write against a stale row.

Open: 11before loopopen ›Open: 22before modelopen ›Open: 33after modelopen ›Open: 44before toolopen ›Open: 55the toolopen ›Open: 66after toolopen ›Open: 77after loopopen ›Open: 88before replyopen ›It readswhen each row was last readfreshnessrule · harnesspassCarries onfailIf it failsre-read the row firstWHERE IN THE CODE: H loop/freshness.py
The strip at the top shows every check point where this check runs, in dark.

How we took care of it.

  1. Before an irreversible write, a row read more than 30 seconds ago is read again.
  2. The write then goes against what is true now.
It readswhen each row was last read
Kindrule
Provided byharness
If it failsre-read the row first
Where in the codeH loop/freshness.py
Runs at4 · Before the tool
Real exampleGap F-126: rows seen only inside a list are missed (flow 11).

More on this: What goes in.

How it is done: the real code

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

async def refreshed(planned: list[tuple[ToolCall, IdempotencyKey]], run: Run) -> bool:
    """`refresh`, put into the run's transcript; whether anything was re-read."""
    held = await refresh(
        planned,
        fresh=run.fresh,
        registry=run.registry,
        tools=run.tools,
        identity=run.identity,
        run_id=run.run_id,
        iteration=len(run.trace.tool_calls),
        now=run.now(),
        span=run.span,
    )
    run.messages.extend(held.messages)
    run.seen_results.extend(held.results)
    return bool(held.messages)