One turn of the agent loop

One turn of the agent loop A workflow diagram generated by Archify. 01 / TUI or dave run 02 / AgentLoop.run_turn EX / Hooks (tighten only) EX / Gate and tools Intake Provider round (repeat) Finish Composer · message · @ · pastes · TUI or dave run › Intake Composer message · @ · pastes Transcript · reply + activity feed · TUI or dave run › Finish Transcript reply + activity feed Prepare turn · @ under the gate · AgentLoop.run_turn › Intake · checkpoint turn Prepare turn @ under the gate checkpoint turn Context catalog · budget · compact · rebuild · AgentLoop.run_turn › Provider round (repeat) Context catalog budget · compact · rebuild Provider round · stream text + calls · AgentLoop.run_turn › Provider round (repeat) Provider round stream text + calls Finish · append to session JSONL · AgentLoop.run_turn › Finish Finish append to session JSONL PreToolUse hooks · deny · ask · allow ignored · Hooks (tighten only) › Provider round (repeat) PreToolUse hooks deny · ask · allow ignored PostToolUse hooks · context on the result · Hooks (tighten only) › Provider round (repeat) PostToolUse hooks context on the result PermissionGate · allow · deny · ask · Gate and tools › Provider round (repeat) PermissionGate allow · deny · ask Approval card · once · session · project · Gate and tools › Provider round (repeat) Approval card once · session · project Run tools · parallel when safe · Gate and tools › Finish Run tools parallel when safe allowed ask tool calls not denied no tool calls request results, next round send Legend User UI Agent logic Policy Tool action Cloud service

The loop

  • • core/loop.py yields AgentEvents; TUI and dave run render them
  • • Rounds repeat until no calls or max_tool_rounds

Gate and tools

  • • Denied calls return a denial as the tool result
  • • Checkpoints snapshot files before writes, for /rewind

Task boundaries

  • • Busy switches wait or cancel before changing Task association
  • • Outgoing output and queued input remain with the old conversation

Task time boundaries

  • • A single device lease counts active model/tool work. Permission waits permit idle. Ten-second evidence caps crash recovery; completed child attribution falls back after memory capture.

General and sidequests

  • • General uses ordinary permissions and isolated child memory/time. Reviewed promotion retains IDs and relocates owned data once.
  • • Sidequests offer Save or Save and switch. Busy switches wait/cancel; failed adoption restores old selection and manual pause.
  • • Missing-checkout returns offer attach or memory-only work; tool filtering and the gate both enforce the restriction.