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.
How we took care of it.
- Before each model call, compare time used with the 60-second turn budget.
- If over, end with deadline_reached; if Rohan has gone, end with caller_gone.
| It reads | the clock, and whether Rohan's connection is still open |
| Kind | rule |
| Provided by | harness |
| If it fails | stop the turn: "let me pass you to a colleague" |
| Where in the code | _out_of_time() · H loop/__init__.py:233 |
| Runs at | 2 · 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