Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

serve: /v1/responses accepts Codex's additional_tools input items (#782)

Niko1221a681cac6a85b
diff --git a/serve/responses.py b/serve/responses.py
index 01f2b17d3..616111eec 100644
--- a/serve/responses.py
+++ b/serve/responses.py
@@ -191,6 +191,8 @@ def input_messages(req: dict) -> list[dict]:
messages.append({"role": "tool", "content": _tool_output(item, param), "_call_id": item.get("call_id")})
open_turn = None
thinking.clear()
+ elif kind == "additional_tools":
+ continue # #782 (Codex): tools the client adds as an input item; see request_tools
elif kind == "item_reference":
raise ResponsesError("item references need stored responses, and this server keeps none: send the items "
"themselves", param, "unsupported_parameter")
@@ -237,6 +239,12 @@ def request_tools(req: dict):
given = req.get("tools") or []
if not isinstance(given, list):
raise ResponsesError("tools must be an array", "tools")
+ # #782 (Codex v0.160): `additional_tools` input items carry more tool definitions (a `tools` array, as the request
+ # has); they join the request's own, and an item without a usable array adds nothing
+ extra = [t for item in (req.get("input") if isinstance(req.get("input"), list) else [])
+ if isinstance(item, dict) and item.get("type") == "additional_tools" and isinstance(item.get("tools"), list)
+ for t in item["tools"]]
+ given = list(given) + extra
def add(tool, param, namespace=None, ns_description=""):
kind = tool.get("type")
diff --git a/serve/test_responses.py b/serve/test_responses.py
index b146852d6..939d4e117 100644
--- a/serve/test_responses.py
+++ b/serve/test_responses.py
@@ -115,6 +115,17 @@ class Parsing(unittest.TestCase):
self.assertEqual(skipped, ["web_search"])
self.assertIsNone(request_tools({"tools": TOOLS, "tool_choice": "none"})[0])
+ def test_additional_tools_input_items_are_accepted(self):
+ """#782: Codex sends an `additional_tools` input item; it used to be refused with a 400."""
+ extra = {"type": "additional_tools", "tools": [{"type": "function", "name": "later_tool",
+ "parameters": {"type": "object"}}]}
+ req = {"input": [{"type": "message", "role": "user", "content": "hi"}, extra,
+ {"type": "additional_tools"}], "tools": TOOLS}
+ self.assertEqual([m["role"] for m in input_messages(req)], ["user"])
+ tools, names, _ = request_tools(req)
+ self.assertEqual([t["name"] for t in tools], ["exec_command", "later_tool"])
+ self.assertIn("later_tool", names)
+
def test_effort_and_text_format(self):
self.assertEqual(template_kwargs({"reasoning": {"effort": "minimal"}}, {}), {"enable_thinking": False})
self.assertEqual(template_kwargs({"reasoning": {"effort": "high"}}, {}), {"reasoning_effort": "xhigh"})