From d2dee43825e30fc2ba61820dcf5b6b1df5e7c9aa Mon Sep 17 00:00:00 2001 From: teknium1 Date: Wed, 11 Mar 2026 07:00:14 -0700 Subject: [PATCH] fix: allow tool_choice, parallel_tool_calls, prompt_cache_key in codex preflight MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _preflight_codex_api_kwargs rejected these three fields as unsupported, but _build_api_kwargs adds them to every codex request. This caused a ValueError before _interruptible_api_call was reached, which was caught by the retry loop and retried with exponential backoff — appearing as an infinite hang in tests (275s total backoff across 6 retries). The fix adds these keys to allowed_keys and passes them through to the normalized request dict. This fixes the hanging test_cron_run_job_codex_path_handles_internal_401_refresh test (now passes in 2.6s instead of timing out). --- run_agent.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/run_agent.py b/run_agent.py index 6e9fc2c38..295106e3d 100644 --- a/run_agent.py +++ b/run_agent.py @@ -1781,6 +1781,7 @@ class AIAgent: allowed_keys = { "model", "instructions", "input", "tools", "store", "reasoning", "include", "max_output_tokens", "temperature", + "tool_choice", "parallel_tool_calls", "prompt_cache_key", } normalized: Dict[str, Any] = { "model": model, @@ -1806,6 +1807,12 @@ class AIAgent: if isinstance(temperature, (int, float)): normalized["temperature"] = float(temperature) + # Pass through tool_choice, parallel_tool_calls, prompt_cache_key + for passthrough_key in ("tool_choice", "parallel_tool_calls", "prompt_cache_key"): + val = api_kwargs.get(passthrough_key) + if val is not None: + normalized[passthrough_key] = val + if allow_stream: stream = api_kwargs.get("stream") if stream is not None and stream is not True: