The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(codex): send reasoning.effort none explicitly; no reasoning field for chat-era OpenAI models
teknium13e74037cf9ca
diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.pyindex 6930558f02b..774b298880e 100644--- a/agent/auxiliary_client.py+++ b/agent/auxiliary_client.py@@ -1464,18 +1464,23 @@ class _CodexCompletionsAdapter:if isinstance(service_tier, str) and service_tier.strip() and not is_xai:resp_kwargs["service_tier"] = service_tier.strip()reasoning_cfg = extra_body.get("reasoning")- # ``enabled: False`` leaves reasoning/include unset (Codex still thinks by default).- if isinstance(reasoning_cfg, dict) and reasoning_cfg.get("enabled") is not False:- # Truthy-only: Codex 400s on e.g. {"effort": null}, so falsy → default. Shared- # per-model clamp with the main transport ("max" is gpt-5.6-only; "minimal"/"ultra" rejected).+ if isinstance(reasoning_cfg, dict):+ # Shared per-model vocabulary with the main transport ("max" is gpt-5.6-only; "minimal"/"ultra"+ # rejected; ``()`` = the model takes no ``reasoning`` field at all — gpt-4o/4.1 on api.openai.com,+ # #76255). ``enabled: False`` goes on the wire as ``effort: none`` where the vocabulary has it,+ # since an omitted field leaves the model's default effort on (#75227).from agent.reasoning_effort import clamp_effortfrom agent.transports.codex import _codex_efforts_for_route- effort = clamp_effort(- reasoning_cfg.get("effort") or "medium",- _codex_efforts_for_route(model, host, is_codex_backend=route.is_codex_backend),- )- resp_kwargs["reasoning"] = {"effort": effort, "summary": "auto"}- resp_kwargs["include"] = ["reasoning.encrypted_content"]+ supported = _codex_efforts_for_route(model, host, is_codex_backend=route.is_codex_backend)+ if not supported:+ pass+ elif reasoning_cfg.get("enabled") is not False:+ # Truthy-only: Codex 400s on e.g. {"effort": null}, so falsy → default.+ effort = clamp_effort(reasoning_cfg.get("effort") or "medium", supported)+ resp_kwargs["reasoning"] = {"effort": effort, "summary": "auto"}+ resp_kwargs["include"] = ["reasoning.encrypted_content"]+ elif "none" in supported and not is_xai:+ resp_kwargs["reasoning"] = {"effort": "none"}if wire_tools:resp_kwargs["tools"] = wire_toolsif wire_aliases:diff --git a/agent/model_metadata.py b/agent/model_metadata.pyindex a129371ab17..4fe598af96e 100644--- a/agent/model_metadata.py+++ b/agent/model_metadata.py@@ -416,6 +416,21 @@ def grok_supports_reasoning_effort(model: str) -> bool:return bool(name) and any(name.startswith(prefix) for prefix in _GROK_EFFORT_CAPABLE_PREFIXES)+# OpenAI chat-era families served on api.openai.com that 400 on ANY ``reasoning`` field+# ("Unsupported parameter: 'reasoning.effort' is not supported with this model"): gpt-3.5,+# gpt-4 / gpt-4-turbo / gpt-4o / gpt-4.1 / gpt-4.5 and the chatgpt-* snapshots. A denylist so+# an unknown future OpenAI model keeps its effort dial (fail-open); ``ft:`` fine-tune ids are+# ``ft:<base>:<org>::<id>`` and inherit the base model's contract.+_OPENAI_NON_REASONING_RE = re.compile(r"^(?:ft:)?(?:gpt-3\.5|gpt-4(?![0-9])|chatgpt-)")+++def openai_model_rejects_reasoning(model: str) -> bool:+ """True for an OpenAI model id (aggregator ``openai/`` prefix stripped) that rejects the+ Responses ``reasoning`` parameter outright, so callers send no ``reasoning`` key at all."""+ name = (model or "").strip().lower().rsplit("/", 1)[-1]+ return bool(_OPENAI_NON_REASONING_RE.match(name))++def is_grok_46_family(model: str) -> bool:"""Whether *model* is a Grok 4.6 family identifier."""name = (model or "").strip().lower().replace("_", "-").rsplit("/", 1)[-1]diff --git a/agent/transports/codex.py b/agent/transports/codex.pyindex 98112f75800..4ee2277dc70 100644--- a/agent/transports/codex.py+++ b/agent/transports/codex.py@@ -223,8 +223,11 @@ def _alias_wire_tools(response_tools: Any, params: dict[str, Any], is_xai_respondef _resolve_reasoning(model: str, params: dict[str, Any]) -> tuple[Any, bool]:"""``(effort, enabled)`` for the request, effort clamped (never escalated) to the endpoint's vocabulary.- A profile-declared ``()`` means "no reasoning parameters accepted" (400 on any- reasoning field) and disables reasoning outright.+ A profile-declared ``()`` (or a model that takes no ``reasoning`` field on its route) means "no+ reasoning parameters accepted" (400 on any reasoning field) and disables reasoning outright:+ ``(None, False)``. An explicit ``reasoning_effort: none`` on a route whose vocabulary has ``none``+ resolves to ``("none", False)`` so the disable goes on the wire instead of being omitted — omitting+ it re-enables the model's default effort (gpt-5.6 defaults to ``medium``, #75227)."""reasoning_effort, reasoning_enabled = "medium", Truereasoning_config = params.get("reasoning_config")@@ -252,9 +255,13 @@ def _resolve_reasoning(model: str, params: dict[str, Any]) -> tuple[Any, bool]:declared = Noneif not (is_codex_backend or _is_openai_api_origin(base_url)):declared = _profile_declared_efforts(params.get("provider"), model, base_url)- if declared is not None and not declared:- reasoning_enabled = False- supported = declared or _codex_efforts_for_route(model, base_url, is_codex_backend=is_codex_backend)+ supported = declared if declared is not None else _codex_efforts_for_route(+ model, base_url, is_codex_backend=is_codex_backend)+ if not supported:+ return None, False+ if not reasoning_enabled:+ has_none = any(str(level).strip().lower() == "none" for level in supported)+ return ("none" if has_none else None), Falsereturn clamp_effort(reasoning_effort, supported), reasoning_enabled@@ -303,7 +310,17 @@ def _is_official_openai_responses_route(model: Any, base_url: Any) -> bool:def _codex_efforts_for_route(model: Any, base_url: Any, *, is_codex_backend: bool = False) -> tuple[str, ...]:- """Keep Astra's new vocabulary off unrelated Responses-compatible endpoints."""+ """Effort vocabulary for a Responses route; ``()`` when the model takes no ``reasoning`` field at all.++ Keeps Astra's new vocabulary off unrelated Responses-compatible endpoints, and sends nothing for the+ chat-era OpenAI families (gpt-4o, gpt-4.1, ...) on api.openai.com, which 400 on any ``reasoning``+ key (#76255). Only the exact OpenAI origin is judged: a relay serving those ids may translate.+ """+ if not is_codex_backend and _is_openai_api_origin(base_url):+ from agent.model_metadata import openai_model_rejects_reasoning++ if openai_model_rejects_reasoning(str(model or "")):+ return ()if is_astra_model(model) and not (is_codex_backend or _is_official_openai_responses_route(model, base_url)):@@ -493,7 +510,9 @@ def _reasoning_fields("""``reasoning`` / ``include`` request fields for the endpoint family.xAI 400s on ``reasoning.effort`` outside its allowlist; GitHub Models takes a- verbatim ``github_reasoning_extra`` and never ``include``.+ verbatim ``github_reasoning_extra`` and never ``include``. A disabled ask resolved to+ ``effort="none"`` is sent as ``{"effort": "none"}`` — the wire has no other way to switch+ a reasoning model's default effort off (#75227)."""include = ["reasoning.encrypted_content"] if replay_encrypted_reasoning else []fields: dict[str, Any] = {}@@ -512,6 +531,8 @@ def _reasoning_fields(fields["include"] = includeelif not is_github_responses and not is_xai_responses:fields["include"] = []+ if effort == "none":+ fields["reasoning"] = {"effort": "none"}return fieldsdiff --git a/tests/agent/test_auxiliary_client.py b/tests/agent/test_auxiliary_client.pyindex 06570e42fef..1611bbfdfe0 100644--- a/tests/agent/test_auxiliary_client.py+++ b/tests/agent/test_auxiliary_client.py@@ -3269,6 +3269,23 @@ class TestCodexAdapterReasoningTranslation:)assert captured.get("reasoning") == {"effort": "low", "summary": "auto"}+ def test_disabled_reasoning_is_sent_as_none_and_chat_era_models_get_no_field(self):+ """#75227 / #76255 on the auxiliary Responses path: ``enabled: False`` goes on the wire as+ ``effort: none`` (omitting it keeps the model's default effort on); a chat-era OpenAI model on+ api.openai.com gets no ``reasoning`` key at all, since it 400s on the field."""+ adapter, captured = self._build_adapter()+ adapter._client.base_url = "https://api.openai.com/v1"+ adapter.create(messages=[{"role": "user", "content": "hi"}], extra_body={"reasoning": {"enabled": False}})+ assert captured.get("reasoning") == {"effort": "none"}+ assert "include" not in captured++ adapter, captured = self._build_adapter()+ adapter._client.base_url = "https://api.openai.com/v1"+ adapter._model = "gpt-4o-mini"+ adapter.create(model="gpt-4o-mini", messages=[{"role": "user", "content": "hi"}],+ extra_body={"reasoning": {"effort": "medium"}})+ assert "reasoning" not in captured+diff --git a/tests/agent/transports/test_codex_transport.py b/tests/agent/transports/test_codex_transport.pyindex 3ac83698e6f..58c4a2be949 100644--- a/tests/agent/transports/test_codex_transport.py+++ b/tests/agent/transports/test_codex_transport.py@@ -1865,3 +1865,32 @@ class TestPreflightSlashEnumStrip:assert params["properties"]["model_id"].get("enum") == ["Qwen/Qwen3.5-0.8B", "plain-id"]+++class TestOpenAIReasoningWireProjection:+ """Explicit ``reasoning_effort: none`` and non-reasoning OpenAI models on the Responses wire+ (#75227, #76255): a disable is sent as ``effort: none`` where the model accepts it — omitting the+ field leaves the model's default effort on — and chat-era models on api.openai.com, which 400 on any+ ``reasoning`` key, get no ``reasoning`` field at all."""++ OPENAI = "https://api.openai.com/v1"++ def _reasoning(self, transport, model, reasoning_config, base_url=OPENAI):+ kw = transport.build_kwargs(model=model, messages=[{"role": "user", "content": "Hi"}], tools=[],+ base_url=base_url, reasoning_config=reasoning_config)+ return kw.get("reasoning")++ def test_explicit_none_is_sent_and_unset_keeps_the_default(self, transport):+ assert self._reasoning(transport, "gpt-5.6-sol", {"enabled": False}) == {"effort": "none"}+ assert self._reasoning(transport, "gpt-5.6-sol", None) == {"effort": "medium", "summary": "auto"}+ # Astra's vocabulary has no ``none``: nothing to send, never an escalated level.+ assert self._reasoning(transport, "gpt-6-astra", {"enabled": False}) is None++ @pytest.mark.parametrize("model", ["gpt-4o-mini", "gpt-4.1-mini", "openai/gpt-4o", "ft:gpt-4o-mini:acme::abc1"])+ def test_chat_era_openai_models_get_no_reasoning_field_on_the_official_origin(self, transport, model):+ for rc in (None, {"enabled": True, "effort": "high"}, {"enabled": False}):+ assert self._reasoning(transport, model, rc) is None, (model, rc)+ # Reasoning models on the same origin and the same id on a relay keep the dial (the relay may translate).+ assert self._reasoning(transport, "o4-mini", None) == {"effort": "medium", "summary": "auto"}+ assert self._reasoning(transport, model, {"enabled": True, "effort": "high"},+ base_url="https://relay.example.com/v1") == {"effort": "high", "summary": "auto"}diff --git a/website/docs/user-guide/configuration.md b/website/docs/user-guide/configuration.mdindex 04c881e30c1..39c8d6376c3 100644--- a/website/docs/user-guide/configuration.md+++ b/website/docs/user-guide/configuration.md@@ -1844,6 +1844,10 @@ The dict form is set by editing `config.yaml` directly: the `/reasoning` menus,Model ids contain dots (`claude-opus-4.5`, `qwen3.6:27b`), which `hermes config set` treats as nesting separators. Escape them with a backslash to write the literal key — `hermes config set 'agent.reasoning_overrides.ollama-local/qwen3\.6:27b-q4_k_m' low` — or edit the YAML directly. See [Dots inside key names](../reference/cli-commands.md#dots-inside-key-names).:::+:::note OpenAI Responses (`openai-api`, `openai-codex`)+`reasoning_effort: none` is sent explicitly as `reasoning.effort: "none"` on models that accept it (GPT-5.x): omitting the field would leave the model's default effort on (GPT-5.6 defaults to `medium`). An unset effort is the only state that omits the field. Chat-era models on `api.openai.com` (`gpt-4o`, `gpt-4.1`, their `-mini` variants and fine-tunes) reject any `reasoning` parameter, so Hermes sends none for them regardless of the configured effort instead of failing with `400 Unsupported parameter: 'reasoning.effort'`. If a model rejects `none`, Hermes warns, drops the disable for the session and retries with the model's default.+:::+:::note Local OpenAI-compatible endpointsA custom `base_url` (`http://localhost:11434/v1`, a vLLM, SGLang or router endpoint) receives the resolved effort — `agent.reasoning_effort` or the matching per-model override — as the standard top-level `reasoning_effort` request field, clamped to the values the OpenAI-compatible wire accepts (`none`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`). The nested `reasoning` object is reserved for endpoints known to accept it (Nous Portal, OpenRouter reasoning-capable models, GitHub Models) because arbitrary servers reject unknown fields with HTTP 400. If your server reads its thinking budget from a different field (Ollama's `think`, vLLM's `chat_template_kwargs`, a router-specific key), set it under the custom provider's [`extra_body`](../integrations/providers.md#named-custom-providers), which is merged into every request routed there.:::@@ -1855,7 +1859,7 @@ A custom `base_url` (`http://localhost:11434/v1`, a vLLM, SGLang or router endpo3. Global `agent.reasoning_effort`4. Provider default-The override applies automatically everywhere: CLI startup, messaging gateway, Desktop/TUI, cron jobs, `/model` mid-session switches (including a switch issued before the first message), session resume (`--resume`, `/resume`), `/new`, and fallback model activation.+The override applies automatically everywhere: CLI startup, `hermes -p` one-shots, messaging gateway, Desktop/TUI, ACP sessions, cron jobs, `/model` mid-session switches (including a switch issued before the first message), session resume (`--resume`, `/resume`), `/new`, and fallback model activation.## Fast Mode