One turn through Gemini CLI
architecture node:
User input:
Representation at this boundary
Source modules
Loop map
One pass — TUI prompt →
sendMessageStream → processTurn (turn budget → loop guard → model router → Turn.run) → tool scheduler (Validating → Scheduled → executing) → approval gauntlet (hook → policy → taint → confirmation bus) → submitQuery continuation. Every turn re-routes the model, even when the previous choice was fine.Decided, not derived — the model is selected per turn by a strategy chain, the tools are approved per call by a TOML policy engine, and the loop itself is split across a package boundary (core streams, CLI schedules). Nothing about a turn is implicit; every choice has a module, a log line, and a telemetry event.
Two guards on looping — the cheap loop detector aborts repeated prompts before the model is called; the next-speaker LLM check decides after the turn whether the model should continue. A turn that ends with no tool calls is not over until the check says so. The next prompt re-enters at step 1.