cleandataengineering.aiAgent Harness, drawn simply
You are here: End to end › Checks › 2 · Before the model › out of time?

Agent Harness Tutorial · End to end · Zoom level 3

How we take care of it: out of time?

out of time? catches the 60 s deadline, or Rohan left.

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 readsthe clock, and whether Rohan'sconnection is still openout of time?rule · harnesspassCarries onfailIf it failsstop the turn: "let me pass you to aWHERE IN THE CODE: _out_of_time() · H loop/__init__.py:233
The strip at the top shows every check point where this check runs, in dark.

How we took care of it.

  1. Before each model call, compare time used with the 60-second turn budget.
  2. If over, end with deadline_reached; if Rohan has gone, end with caller_gone.
It readsthe clock, and whether Rohan's connection is still open
Kindrule
Provided byharness
If it failsstop the turn: "let me pass you to a colleague"
Where in the code_out_of_time() · H loop/__init__.py:233
Runs at2 · Before the model
Real exampleNo real turn has hit it yet; the slowest was flow 2's first turn at 10.5 s.

More on this: When it stops.

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 _out_of_time(self) -> Ended | None:
        """The deadline, and the caller leaving, which ends a turn as surely (AHC-0096)."""
        if self.now() - self.started > self.budgets.max_turn_seconds:
            return self._stop(TerminationReason.DEADLINE_REACHED, PASS_ON)
        if await self._caller_gone():
            return self._stop(TerminationReason.CALLER_GONE, CALLER_LEFT)
        return None