This commit is contained in:
Stephen Chin 2026-09-28 11:29:43 -07:00 • committed by GitHub
commit 3b48cbeb1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 1 deletions

View file

@ -2458,6 +2458,8 @@ class BaseLLMHTTPHandler:
)
)
stream = bool(stream or data.get("stream"))
logging_obj.stream = stream # rebind-ok: record provider-resolved stream mode
logging_obj.model_call_details.update(stream=stream)
# Preserve the OpenAI-style request context (not sent to the provider) for streaming
# hooks/metadata; the streaming iterator now consumes this to run deployment hooks
@ -2650,6 +2652,8 @@ class BaseLLMHTTPHandler:
)
)
stream = bool(stream or data.get("stream"))
logging_obj.stream = stream # rebind-ok: record provider-resolved stream mode
logging_obj.model_call_details.update(stream=stream)
# Preserve the OpenAI-style request context (not sent to the provider) for streaming
# hooks/metadata; the streaming iterator now consumes this to run deployment hooks

View file

@ -197,6 +197,10 @@ def test_prepare_fake_stream_request():
def test_response_api_handler_streams_when_provider_transform_adds_stream():
from datetime import datetime
from litellm.litellm_core_utils.litellm_logging import Logging
handler = BaseLLMHTTPHandler()
config = Mock()
config.validate_environment.return_value = {}
@ -214,7 +218,22 @@ def test_response_api_handler_streams_when_provider_transform_adds_stream():
request=httpx.Request("POST", "https://chatgpt.example.com/responses"),
)
)
logging_obj = Mock()
logging_obj = Logging(
model="gpt-5.3-codex",
messages=[{"role": "user", "content": "hi"}],
stream=False,
call_type="completion",
start_time=datetime.now(),
litellm_call_id="test-call",
function_id="test-function",
)
logging_obj.update_environment_variables(
model="gpt-5.3-codex",
user=None,
optional_params={"stream": False},
litellm_params={},
custom_llm_provider="chatgpt",
)
handler.response_api_handler(
model="gpt-5.3-codex",
@ -229,6 +248,10 @@ def test_response_api_handler_streams_when_provider_transform_adds_stream():
assert client.post.call_args.kwargs["stream"] is True
assert client.post.call_args.kwargs["json"]["stream"] is True
assert logging_obj.stream is True
assert logging_obj.model_call_details["stream"] is True
logging_obj.has_run_logging(event_type="async_success")
assert logging_obj.should_run_logging(event_type="async_success") is True
def test_response_api_handler_runs_agentic_hooks_in_sync_path(monkeypatch):
@ -356,6 +379,7 @@ async def test_async_response_api_handler_streams_when_provider_transform_adds_s
)
)
logging_obj = Mock()
logging_obj.model_call_details = {}
await handler.async_response_api_handler(
model="gpt-5.3-codex",
@ -370,6 +394,8 @@ async def test_async_response_api_handler_streams_when_provider_transform_adds_s
assert client.post.call_args.kwargs["stream"] is True
assert client.post.call_args.kwargs["json"]["stream"] is True
assert logging_obj.stream is True
assert logging_obj.model_call_details["stream"] is True
@pytest.mark.asyncio