diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.py index 4c706748a0..62695af83a 100644 --- a/agent/auxiliary_client.py +++ b/agent/auxiliary_client.py @@ -567,7 +567,12 @@ class _CodexCompletionsAdapter: # API allows it. pass else: - effort = reasoning_cfg.get("effort", "medium") + # Truthy-only check mirrors agent/transports/codex.py + # build_kwargs(): falsy values (None, "", 0) fall back + # to the default rather than being forwarded to the + # Codex backend, which rejects e.g. {"effort": null} + # with a 400. + effort = reasoning_cfg.get("effort") or "medium" # Codex backend rejects "minimal"; clamp to "low" to # match the main-agent Codex transport behavior. if effort == "minimal": diff --git a/tests/agent/test_auxiliary_client.py b/tests/agent/test_auxiliary_client.py index 43125554df..a42b6fc877 100644 --- a/tests/agent/test_auxiliary_client.py +++ b/tests/agent/test_auxiliary_client.py @@ -1650,6 +1650,30 @@ class TestCodexAdapterReasoningTranslation: ) assert "reasoning" not in captured + def test_reasoning_effort_null_falls_back_to_medium(self): + """Parity with agent/transports/codex.py::build_kwargs() — falsy + ``effort`` (None / empty / 0) keeps the default ``medium`` instead + of being forwarded to Codex. Codex rejects ``{"effort": null}`` + with HTTP 400 (Invalid value for parameter `reasoning.effort`).""" + adapter, captured = self._build_adapter() + adapter.create( + messages=[{"role": "user", "content": "hi"}], + extra_body={"reasoning": {"effort": None}}, + ) + assert captured.get("reasoning") == {"effort": "medium", "summary": "auto"} + assert captured.get("include") == ["reasoning.encrypted_content"] + + def test_reasoning_effort_empty_string_falls_back_to_medium(self): + """Empty-string effort (e.g. ``effort: ""`` in YAML) is falsy in + the main-agent path's truthy check; mirror that here so the same + config produces the same result.""" + adapter, captured = self._build_adapter() + adapter.create( + messages=[{"role": "user", "content": "hi"}], + extra_body={"reasoning": {"effort": ""}}, + ) + assert captured.get("reasoning") == {"effort": "medium", "summary": "auto"} + assert captured.get("include") == ["reasoning.encrypted_content"] class TestVisionAutoSkipsKimiCoding: