From a82ce602946637929bab454b368c2dd522e9889b Mon Sep 17 00:00:00 2001 From: teknium1 Date: Wed, 11 Mar 2026 04:28:31 -0700 Subject: [PATCH] fix: add missing Responses API parameters for Codex provider MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds tool_choice, parallel_tool_calls, and prompt_cache_key to the Codex Responses API request kwargs — matching what the official Codex CLI sends. - tool_choice: 'auto' — enables the model to proactively call tools. Without this, the model may default to not using tools, which explains reports of the agent claiming it lacks shell access (#747). - parallel_tool_calls: True — allows the model to issue multiple tool calls in a single turn for efficiency. - prompt_cache_key: session_id — enables server-side prompt caching across turns in the same session, reducing latency and cost. Refs #747 --- run_agent.py | 3 +++ tests/test_run_agent_codex_responses.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/run_agent.py b/run_agent.py index 57e2a13b..9b3a7dba 100644 --- a/run_agent.py +++ b/run_agent.py @@ -2340,7 +2340,10 @@ class AIAgent: "instructions": instructions, "input": self._chat_messages_to_responses_input(payload_messages), "tools": self._responses_tools(), + "tool_choice": "auto", + "parallel_tool_calls": True, "store": False, + "prompt_cache_key": self.session_id, } if reasoning_enabled: diff --git a/tests/test_run_agent_codex_responses.py b/tests/test_run_agent_codex_responses.py index a1e5e817..cf2694f0 100644 --- a/tests/test_run_agent_codex_responses.py +++ b/tests/test_run_agent_codex_responses.py @@ -235,6 +235,10 @@ def test_build_api_kwargs_codex(monkeypatch): assert kwargs["tools"][0]["strict"] is False assert "function" not in kwargs["tools"][0] assert kwargs["store"] is False + assert kwargs["tool_choice"] == "auto" + assert kwargs["parallel_tool_calls"] is True + assert isinstance(kwargs["prompt_cache_key"], str) + assert len(kwargs["prompt_cache_key"]) > 0 assert "timeout" not in kwargs assert "max_tokens" not in kwargs assert "extra_body" not in kwargs