From e1d4f1e11e04b60108f02026ddb61e37028439da Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 19 May 2026 05:51:10 +0000 Subject: [PATCH] refactor: name streaming response finalizer Agent-Logs-Url: https://github.com/microsoft/agent-framework/sessions/f62076ef-558d-49e8-8fe2-f38d527c9639 Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com> --- .../openai/agent_framework_openai/_chat_client.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/python/packages/openai/agent_framework_openai/_chat_client.py b/python/packages/openai/agent_framework_openai/_chat_client.py index 535c9d9a6b..080e4a7803 100644 --- a/python/packages/openai/agent_framework_openai/_chat_client.py +++ b/python/packages/openai/agent_framework_openai/_chat_client.py @@ -615,6 +615,12 @@ class RawOpenAIChatClient( # type: ignore[misc] seen_reasoning_delta_item_ids: set[str] = set() validated_options: dict[str, Any] | None = None + def _finalize_streamed_response(updates: Sequence[ChatResponseUpdate]) -> ChatResponse[Any]: + return self._finalize_response_updates( + updates, + response_format=validated_options.get("response_format") if validated_options else None, + ) + async def _stream() -> AsyncIterable[ChatResponseUpdate]: nonlocal validated_options if continuation_token is not None: @@ -681,13 +687,7 @@ class RawOpenAIChatClient( # type: ignore[misc] except Exception as ex: self._handle_request_error(ex) - return ResponseStream( - _stream(), - finalizer=lambda updates: self._finalize_response_updates( - updates, - response_format=validated_options.get("response_format") if validated_options else None, - ), - ) + return ResponseStream(_stream(), finalizer=_finalize_streamed_response) # Non-streaming async def _get_response() -> ChatResponse: