From 30cc15975e87fb7202f5e7a0abae9ac69feff660 Mon Sep 17 00:00:00 2001 From: nesquena-hermes Date: Sat, 13 Jun 2026 18:50:00 +0000 Subject: [PATCH] fix(#4130): coerce stale 'max' in get_reasoning_status read path too (Codex catch) get_reasoning_status() returned the raw config reasoning_effort, so a stale saved 'max' surfaced on boot/status/chip even though streaming coerces it to xhigh. Now routes the status value through coerce_reasoning_effort_for_model() with the resolved model/provider/base_url, so all read paths agree. Added a stale-max->xhigh status regression test. --- api/config.py | 11 ++++++++++- .../test_reasoning_effort_model_capabilities.py | 17 +++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/api/config.py b/api/config.py index 6f3c2b75d..f6058dd0a 100644 --- a/api/config.py +++ b/api/config.py @@ -2734,7 +2734,16 @@ def get_reasoning_status( return { # Match CLI default (True if unset in config.yaml) "show_reasoning": bool(show_raw) if isinstance(show_raw, bool) else True, - "reasoning_effort": str(effort_raw or "").strip().lower(), + # Report the COERCED effort (not the raw config value) so boot/status/chip + # read paths agree with what streaming actually sends — e.g. a stale + # `reasoning_effort: max` surfaces as `xhigh`, not the now-unsupported `max`. + # (Codex review of the drop-max alignment.) + "reasoning_effort": coerce_reasoning_effort_for_model( + str(effort_raw or "").strip().lower(), + resolve_model, + provider_id=resolve_provider, + base_url=resolve_base_url, + ), "supported_efforts": supported_efforts, "supports_reasoning_effort": bool(supported_efforts), } diff --git a/tests/test_reasoning_effort_model_capabilities.py b/tests/test_reasoning_effort_model_capabilities.py index 0657aaa64..acbac7cc9 100644 --- a/tests/test_reasoning_effort_model_capabilities.py +++ b/tests/test_reasoning_effort_model_capabilities.py @@ -140,3 +140,20 @@ def test_get_reasoning_status_for_reasoning_capable_model_has_no_max(): assert status["supported_efforts"] == ["minimal", "low", "medium", "high", "xhigh"] assert status["supports_reasoning_effort"] is True assert "max" not in status["supported_efforts"] + + +def test_get_reasoning_status_coerces_stale_max_to_xhigh(monkeypatch): + """A previously-saved `agent.reasoning_effort: max` (no longer a valid effort) + must be reported as the coerced `xhigh`, not the raw stale `max`, so the + boot/status/chip read paths agree with what streaming actually sends.""" + monkeypatch.setattr( + cfg, + "_load_yaml_config_file", + lambda *a, **k: {"agent": {"reasoning_effort": "max"}}, + ) + status = cfg.get_reasoning_status( + model_id="gpt-5.5", + provider_id="openai-codex", + ) + assert status["reasoning_effort"] == "xhigh" + assert status["reasoning_effort"] != "max"