codex-agent-loop
Installation
SKILL.md
Codex Agent Loop
Use this skill when you need the durable mental model for how Codex actually runs: how the initial request is assembled, how inference and tool calls loop within a turn, how conversation state grows across turns, and where model_instructions_file, AGENTS.md, and local guidance enter.
Read Order
- Read
references/unrolling-the-codex-agent-loop.mdfor the end-to-end model of threads, turns, items, and tool iteration. - Read
references/building-the-initial-prompt.mdfor the first request, prompt item ordering, tool definitions, and SSE event flow. - Read
references/conversation-growth-and-performance.mdfor prompt growth, exact-prefix caching, statelessness,previous_response_id, ZDR, and compaction. - Read
references/openai-codex-prompt-loading.mdonly when exactmodel_instructions_file,AGENTS.md, or project config semantics matter. - Read
references/prompt-layering.mdonly when deciding what belongs in the base prompt versus local guidance or mutable context.
Core Model
- A
threadis the durable conversation container. - A
turnbegins with a new user request and may contain many inference and tool-call iterations before it ends. - The Responses API request surface is structured as
instructions,tools, andinput; the server derives the actual prompt shape from those parts. - Tool calls are part of the normal loop, and their outputs are appended back into later
inputitems. - Stable early prompt content matters because it affects both behavior and prompt caching efficiency.