Unrolling the Codex agent loop
Deep dive 16 min +160 XP
Codex CLI's agent loop repeatedly sends a prompt to the Responses API, executes any tool calls the model requests, and appends their outputs until the model returns an assistant message that ends the turn.