OpenAI's Codex agent loop deep dive

This OpenAI post is a useful technical read because it explains the agent loop, context construction, model calls, and tool orchestration behind Codex.

Source

Unrolling the Codex agent loop

Why I saved it

I like this kind of article because it goes below the product surface. It explains the harness, not only the model.

For coding agents, the harness is everything around the model: prompt construction, context, tools, command execution, state, and final reporting.

My notes

  • Codex is described as a suite, with the CLI harness as the focus of this article.
  • The core loop is about preparing instructions, calling the model, running tools, and feeding results back.
  • The Responses API endpoint is configurable, which makes the loop portable across compatible endpoints.
  • Good agent behavior depends on how context is prepared and updated, not only on raw model intelligence.

What I want to remember

If I build a coding CLI or agent, I should design the loop as a first-class product. Prompts, tools, permissions, tests, and context management should be code, not hidden magic.