The Codex agent loop, a critical component of OpenAI's Codex CLI, has been extensively documented by Michael Bolin, Codex's lead engineer. The agent loop is responsible for orchestrating the interaction between the user, the model, and the tools invoked to perform meaningful software work.

What Happened

In January 2026, Michael Bolin published a rare technical deep-dive into the agent loop in Codex's internal documentation. This article extracts the practical implications for people building agentic workflows. The documentation provides a detailed explanation of how the agent loop works, including the tokenization process and the quadratic growth problem.

The agent loop is a complex system that involves multiple components working together to produce a final output. It starts with user input, which is then converted into tokens that are sent to the Responses API. The model samples output tokens one at a time, and these tokens are decoded back to text and streamed to the TUI.

Background and Context

Codex CLI is an open-source tool developed by OpenAI that allows users to interact with the Codex model. The model is trained on a massive dataset of code and can perform various tasks such as writing code, debugging, and even creating entire programs from scratch.

The agent loop is a critical component of Codex CLI, and its documentation provides valuable insights into how it works. The tokenization process, in particular, is an important aspect of the agent loop. It involves converting user input into tokens that can be understood by the model.

Why It Matters to the Industry

The documentation of the Codex agent loop has significant implications for the adult industry. One of the key takeaways from the documentation is the quadratic growth problem. This means that every time a new message is sent, the entire conversation history is bundled into the prompt, leading to a significant increase in data sent to the API and costs.

This is particularly relevant to the adult industry, where long sessions are common. The industry relies heavily on AI-powered tools like Codex CLI to perform various tasks such as content moderation, age verification, and payment processing. Understanding how these tools work is crucial for optimizing performance and reducing costs.

What Comes Next

The documentation of the Codex agent loop provides a valuable resource for developers and engineers working in the adult industry. It highlights the importance of understanding how AI-powered tools like Codex CLI work and how to optimize their performance.

In addition, the quadratic growth problem identified in the documentation has significant implications for the development of future AI-powered tools. It highlights the need for more efficient tokenization processes and better management of conversation history.

Key Facts

  • The Codex agent loop is a critical component of OpenAI's Codex CLI, responsible for orchestrating the interaction between the user, the model, and the tools invoked to perform meaningful software work.
  • The agent loop involves multiple components working together to produce a final output, including tokenization, inference, and parsing.
  • The tokenization process converts user input into tokens that can be understood by the model.
  • The quadratic growth problem means that every time a new message is sent, the entire conversation history is bundled into the prompt, leading to a significant increase in data sent to the API and costs.
  • The documentation of the Codex agent loop provides valuable insights into how AI-powered tools like Codex CLI work and highlights the need for more efficient tokenization processes and better management of conversation history.