From 663347d51998d8ef80133c99cd845267799866d8 Mon Sep 17 00:00:00 2001 From: Ahmed Allam Date: Wed, 5 Aug 2026 20:31:02 +0000 Subject: [PATCH] fix(llm): cap the subscription backend's responses too --- strix/config/models.py | 9 +++++---- tests/test_disable_streaming.py | 8 +++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/strix/config/models.py b/strix/config/models.py index 66702479..f14abfcf 100644 --- a/strix/config/models.py +++ b/strix/config/models.py @@ -433,14 +433,15 @@ class StrixProvider(MultiProvider): # The ChatGPT subscription backend is always streamed; it has no # non-streaming mode to fall back to, so LLM_DISABLE_STREAMING # does not apply here. - return _CodexResponsesModel( + model: Model = _CodexResponsesModel( slug, codex.get_subscription_client(), reasoning_effort=llm.reasoning_effort, ) - model = super().get_model(model_name) - if llm.disable_streaming: - model = _NonStreamingModel(model) + else: + model = super().get_model(model_name) + if llm.disable_streaming: + model = _NonStreamingModel(model) return _TurnGuardModel(model, max_tool_calls_per_turn=llm.max_tool_calls_per_turn) diff --git a/tests/test_disable_streaming.py b/tests/test_disable_streaming.py index 8af67ac7..00e99bcc 100644 --- a/tests/test_disable_streaming.py +++ b/tests/test_disable_streaming.py @@ -315,14 +315,16 @@ def test_get_model_keeps_streaming_by_default( assert model._inner is inner -def test_get_model_does_not_wrap_subscription_model( +def test_get_model_guards_subscription_model_but_keeps_it_streaming( monkeypatch: pytest.MonkeyPatch, _reset_settings: None ) -> None: - # Subscription (ChatGPT) models are always streamed and must not be wrapped. + # Subscription (ChatGPT) models are always streamed, so LLM_DISABLE_STREAMING + # must not apply — but a runaway response needs capping there too. monkeypatch.setattr(codex, "subscription_model", lambda *_: "gpt-5.5") monkeypatch.setattr(codex, "get_subscription_client", lambda: AsyncOpenAI(api_key="x")) monkeypatch.setenv("LLM_DISABLE_STREAMING", "true") load_settings() model = StrixProvider().get_model("gpt-5.5") - assert not isinstance(model, _NonStreamingModel) + assert isinstance(model, _TurnGuardModel) + assert not isinstance(model._inner, _NonStreamingModel)