Prompt Construction and Tool Declarations
The tool-call chapter starts when a model requests a tool. Here we follow what Codex sends before the model can make that choice. A prompt in the harness includes ordered conversation items, tool specifications, instructions, and response settings. Prompt fields
Evidence. Source, upstream assertions, and their checked-in request snapshot inspected for Codex CLI 0.172.0. The fixture varies both the provider configuration and the serialization mode. Its regular OpenAI Responses case disables incremental tools, while regular Responses cases for other providers exercise incremental declarations. Read the parameter values before applying a snapshot to a specific configuration. Fixture cases
Where the declarations go
Section titled “Where the declarations go”| Path in the pinned source | What the request carries |
|---|---|
| Regular Responses without incremental tools | build_prompt supplies the active tool specs and base instructions. The client serializes the specs into the request’s top-level tools field and inserts base instructions at the start of input when present. Prompt builder · Request builder |
| Regular Responses with incremental tools | The prompt builder keeps hosted web search among the top-level tools when enabled. Other eligible direct declarations enter the model-visible history. The builder leaves its separate base-instructions field empty because the incremental path handles model instructions in history. Prompt builder · Tool and model state assembly |
| Responses Lite serialization | The client can serialize tool specs still present on the prompt as a developer-role additional_tools input item and leaves the top-level tools value unset. This is a serialization choice. Test whether earlier inputs are preserved to establish that an update was incremental. Request builder · Prefix assertion |
Follow an incremental update
Section titled “Follow an incremental update”- Build the active catalog. The step’s router supplies the model-visible specs. The incremental path filters out hosted web search before constructing its catalog state. Catalog construction
- Compare it with the previous catalog.
TopLevelToolsStatestores hashes and compares each current definition with its previous entry. It collects changed standalone tools and changed members of namespaces. Removal handling runs separately. Catalog diff · Changed definitions - Inspect the requests. The fixture switches from its original model entry to one with a new description for
functions.execand replacement model instructions. The checked-in Regular Responses snapshot shows the previous input followed by a developer notice, anadditional_toolsitem for the changed definition, the replacement instructions, and the current user message. Model change · Request snapshot
What the fixture checks
Section titled “What the fixture checks”It compares the first four requests pairwise and requires each earlier input to be a prefix of the next. It finds the changed functions.exec declaration in request three and checks that the metrics register one schema change. After compaction, it checks that the updated model instructions appear and the old instructions are absent. These assertions establish request shape and history behavior for the fixture. Cache reuse and model compliance require separate measurements. Prefix assertion · Schema change and instructions assertions
Compare requests two and three
Section titled “Compare requests two and three”Read the recorded Regular Responses snapshot side by side with the fixture. Request two adds the user message at index 05. In request three, indices 00–05 are still present. Item 06 announces an update, 07 declares the changed functions.exec, 08 carries the replacement instructions, and 09 holds the new user message. To reconstruct the available tools at item 09, apply the new definition to the earlier catalog. Item 07 alone contains only the change. Snapshot excerpt
Research question
Section titled “Research question”How does the placement of an updated tool schema affect argument validity? Hold tool semantics, user task, and model fixed. Change one required field, then compare requests that replace the full catalog with requests that append the same change. Measure whether the first attempted call uses the updated field and record request size separately.
Check your understanding
Section titled “Check your understanding”- Where would you look for the hosted web-search declaration in the Regular Responses incremental case?
- What observation shows that the runtime appended the tool change without rewriting earlier inputs?
Answers. Inspect top-level tools for hosted web search. Compare the ordered input arrays and verify that the earlier array remains an exact prefix when the changed declaration appears.
Continue with Model Requests and Streaming to follow the request and the response events.