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:
- A
developermessage describing the sandbox and permission rules (applies to the built-in shell tool). - Optional
developerinstructions from config. - A
usermessage with the aggregatedAGENTS.md/ skills instructions. - A
usermessage describing the environment (<environment_context>with cwd and shell). - 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.