fix(llm): cap the subscription backend's responses too

This commit is contained in:
Ahmed Allam
2026-08-06 00:06:49 +03:00
committed by Ahmed Allam
parent da6765f608
commit 663347d519
2 changed files with 10 additions and 7 deletions
+5 -4
View File
@@ -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)
+5 -3
View File
@@ -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)