Skip to content

Agent Zero AI framework

Fix Codex OAuth reasoning effort forwarding

Alessandroed7b0800011d
diff --git a/plugins/_oauth/AGENTS.md b/plugins/_oauth/AGENTS.md
index 9c6406a20..5264e0820 100644
--- a/plugins/_oauth/AGENTS.md
+++ b/plugins/_oauth/AGENTS.md
@@ -44,6 +44,7 @@
- Browser callback providers must support manual callback paste when the browser cannot reach the local callback route.
- Local proxy routes must remain loopback or token protected and must not add broad CORS access.
- Codex Responses proxy requests must include Codex client metadata and compatibility headers such as `client_metadata`, `x-codex-installation-id`, `originator`, `session-id`, and `thread-id`, and must forward `input` as a list for upstream Codex compatibility.
+- Codex Responses proxy requests must translate the legacy top-level `reasoning_effort` field to `reasoning.effort`; an explicit native `reasoning` field takes precedence.
## Work Guidance
diff --git a/plugins/_oauth/helpers/codex.py b/plugins/_oauth/helpers/codex.py
index adcfdaec6..d79025af4 100644
--- a/plugins/_oauth/helpers/codex.py
+++ b/plugins/_oauth/helpers/codex.py
@@ -666,6 +666,9 @@ def fetch_models() -> list[str]:
def prepare_responses_body(body: dict[str, Any], *, force_stream: bool) -> dict[str, Any]:
normalized = dict(body)
+ reasoning_effort = normalized.pop("reasoning_effort", None)
+ if reasoning_effort is not None and "reasoning" not in normalized:
+ normalized["reasoning"] = {"effort": reasoning_effort}
input_value = normalized.get("input")
if isinstance(input_value, str):
normalized["input"] = (
diff --git a/tests/test_oauth_codex.py b/tests/test_oauth_codex.py
index fc4a3159f..5d52734b1 100644
--- a/tests/test_oauth_codex.py
+++ b/tests/test_oauth_codex.py
@@ -207,6 +207,30 @@ def test_prepare_responses_body_adds_codex_client_metadata(monkeypatch):
assert body["include"] == ["output_text", "reasoning.encrypted_content"]
+ ("request_reasoning", "expected"),
+ [
+ ({"reasoning_effort": "xhigh"}, {"effort": "xhigh"}),
+ (
+ {"reasoning": {"effort": "medium"}, "reasoning_effort": "xhigh"},
+ {"effort": "medium"},
+ ),
+ ],
+)
+def test_prepare_responses_body_normalizes_reasoning_effort(
+ monkeypatch, request_reasoning, expected
+):
+ monkeypatch.setattr(codex, "build_client_metadata", lambda: {})
+
+ body = codex.prepare_responses_body(
+ {"model": "gpt-5.5", "input": "hello", **request_reasoning},
+ force_stream=True,
+ )
+
+ assert body["reasoning"] == expected
+ assert "reasoning_effort" not in body
+
+
def test_prepare_responses_body_sends_empty_continuation_input_as_list(monkeypatch):
monkeypatch.setattr(codex, "build_client_metadata", lambda: {})