Pull requests / #1241

#1241 serve: the Responses API reads Codex's additional_tools input items as tools (#782)

closed · @BGonnermann · 0 comentários · No GitHub

Setup & installServer & APIDocumentationWindows

Descrição

Fixes #782.

## The problem

Codex (0.160.0 in the report, and Xcode's bundled Codex agent in the comment) can send its tools inside `input`:

```json
{"type": "additional_tools", "role": "developer", "tools": [ ... ]}
```

`input_messages()` refused the item with a 400 (`input items of type 'additional_tools' are not supported`), so the
request never ran and the client fell back to shell commands.

## What the item is

The issue has only a second-hand description, so I read it in openai/codex:

- `codex-rs/app-server-protocol/schema/typescript/ResponseItem.ts`: `{ "type": "additional_tools", id?, role: string, tools: unknown[] }`.
- `codex-rs/core/tests/suite/responses_lite.rs`: in this mode the request has no `tools` and no `instructions`;
  `input[0]` is the `additional_tools` item and its `tools` are compared with what `tools` holds in the standard mode
  (the same format: `function`, `namespace`, hosted tools).
- `codex-rs/core/tests/suite/scenarios_incremental_tools.rs`: when the tools change, another item is appended. Its
  namespace's `description` is the text "This is an incremental namespace update. Previously declared tools remain
  available ... If a tool is redefined here, its latest definition replaces the earlier one." A removed tool is
  announced by a developer message, not by an item.

## The change

| Where | Change |
|---|---|
| `input_messages()` | An `additional_tools` item makes no message. Without a `tools` array it is a 400 naming `input[i].tools`. |
| `request_tools()` | The tools are `tools`, then those of the `additional_tools` items, in order. So the same tools give the same prompt as the old request form. Errors name `input[i].tools[j]`. |
| `request_tools()` | A tool defined again replaces the earlier definition in its place. |
| `request_tools()` | A namespace keeps the description it was first declared with, so Codex's update note is not shown to the model as the description of the tools. |
| `docs/DETAILS.md` | Two rows of the Responses table. |

## Things to know

- Replacing in place also applies to a name that appears twice in `tools`. Before, both definitions went into the
  prompt. Say so if you want that left as it was.
- Nothing removes a tool: Codex's removal notice is a developer message, and the model reads it as text.
- The tools are at the start of the prompt. When Codex appends an update item, the next request reads the whole prompt
  again instead of continuing from the conversation cache. I did not measure how often Codex does that.

## Tests

`python -m unittest serve.test_responses`: 23 pass (21 before, 2 new), Windows 11, Python 3.14.7, mock engine.

- `test_additional_tools_items`: the item is not a message; its tools equal the ones `tools` would give; an update
  item replaces one member and adds a tool; the namespace description is kept; `tools` come first; `tool_choice: none`;
  three malformed items.
- `AdditionalTools.test_a_request_with_its_tools_in_the_input`: Codex's request form over HTTP, plain and streamed:
  200, a `function_call` comes back, and the prompt the engine got holds the tool and the developer text.

Not tested with a real Codex or a real model: I do not have the setup of the report. @Anivie and @hys17, a run on your
side would settle it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

No site

Links install, modelos, releases.