
It's worth noting that both OpenAI and Anthropic open source their coding CLI clients on GitHub, allowing developers to explore the implementation directly, while they don't do the same for ChatGPT or the Claude web interface.
An official look inside the barrel
Bolin's article focuses on what he calls “the agent loop,” the core logic that orchestrates the interactions between the user, the AI model, and the software tools the model uses to perform coding work.
As we wrote in December, at the heart of any AI agent is a repeating cycle. The agent takes input from the user and prepares a textual prompt for the model. The model then generates a response, which either provides a final answer for the user or requests a tool call (such as running a shell command or reading a file). If the model requests a tool call, the agent executes it, adds the output to the original prompt, and queries the model again. This process repeats until the model stops requesting tools and instead produces an assistant message to the user.
That looping process has to start somewhere, and Bolin's post reveals how Codex constructs the initial prompt sent to OpenAI's Responses API, which handles model inference. The prompt is made up of several components, each with an assigned role that determines priority: system, developer, user, or assistant.
The instruction field comes from a user-specified configuration file or from basic instructions provided with the CLI. The Tools field defines what functions the model can call, including shell commands, scheduling tools, web search capabilities, and any custom tools provided through Model Context Protocol (MCP) servers. The input field contains a series of items describing the sandbox permissions, optional developer instructions, environment context such as the current working directory, and finally the user's actual message.
