The loop
agent/loop.py
for step in range(max_steps)
①
context
.fit()
budget
②
provider
.complete()
the model proposes
③
_record()
append + checkpoint
④
tool_calls?
the exit condition
⑤
policy
.check()
before, not after
⑥
run(call)
the side effect
⑦
role="tool"
results go back
next step
break →
StopReason.END_TURN
{{ line }}
{{ caption }}
messages: {{ msgCount }}
←
{{ playLabel }}
→