Skip to slide
Chapter 3 · Building the Prompt
16 / 142

CHAPTER 03 · Building the Prompt · 2 / 5

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.

Then on later turns, the previous turns' items (assistant messages, tool calls, tool results) are appended, 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.

← → arrow keys work too