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

  1. Read references/unrolling-the-codex-agent-loop.md for the end-to-end model of threads, turns, items, and tool iteration.
  2. Read references/building-the-initial-prompt.md for the first request, prompt item ordering, tool definitions, and SSE event flow.
  3. Read references/conversation-growth-and-performance.md for prompt growth, exact-prefix caching, statelessness, previous_response_id, ZDR, and compaction.
  4. Read references/openai-codex-prompt-loading.md only when exact model_instructions_file, AGENTS.md, or project config semantics matter.
  5. Read references/prompt-layering.md only when deciding what belongs in the base prompt versus local guidance or mutable context.

Core Model

  • A thread is the durable conversation container.
  • A turn begins 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, and input; 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 input items.
  • Stable early prompt content matters because it affects both behavior and prompt caching efficiency.
Installs
13
GitHub Stars
22
First Seen
Jun 11, 2026
codex-agent-loop — wisdom-in-a-nutshell/agents