Skip to slide
026 / 170

CH 03 · Building the Prompt · 03/12

Read as one page

How it works: assembling one request

Putting the pieces together, here is the order Codex inserts items into input before adding your actual message:

  1. A developer message describing the sandbox and permission rules (applies to the built-in shell tool).
  2. Optional developer instructions from config.
  3. A user message with the aggregated AGENTS.md / skills instructions.
  4. A user message describing the environment (<environment_context> with cwd and shell).
  5. Finally, your actual user message.

At the commit the Real code slides quote, the code keeps that shape with two changes: the developer pieces are bundled into one developer message, and the developer instructions from config now come after the AGENTS.md and environment messages. The idea is unchanged: standing instructions first, your message last.

Then on later turns, the previous turns' items (assistant messages, tool calls, tool results) are appended, along with any context section that changed (a new working directory, say), and the old prompt stays an exact prefix of the new one. That prefix property is not an accident; it is engineered, again for caching.

Finished this idea?

Your learning progress stays in this browser.