Skip to content
Learn/

Agent Loops & Checkpointing

1 / 7

An agent is a loop with a budget

An agent repeatedly asks a model what to do next, executes a tool or deterministic step, appends the result to state, and asks again. The model provides decisions inside the loop; the runtime owns the loop itself.

Every production loop needs explicit terminal states: success, user input required, policy refusal, permanent failure, and budget exhausted. Bound model calls, tool calls, elapsed time, tokens, and spend. “Continue until done” is not a stopping condition the infrastructure can enforce.

The transcript grows after every step. Later model calls resend earlier messages and tool results, so token work can grow faster than the step count. Compact old state into typed facts, store large artifacts outside the prompt, and give the model references instead of repeatedly copying entire outputs.

load state → model decision → validate → execute step
    ▲                                      │
    │                                      ▼
    └──────── checkpoint ◀──── append typed result

stop when: success | input required | refused | failed | budget exhausted
Traffic
100req/s
p50
10.78s
p99
19.56s
Errors
0.54%
Availability
99.46%
Cost
$11.33M/mo