Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Fixes #7479 - #7976

Open
sabaka-chabaka wants to merge 1 commit into
dotnet:mainfrom
sabaka-chabaka:fix/issue-7479
Open

sabaka-chabaka wants to merge 1 commit into
dotnet:mainfrom
sabaka-chabaka:fix/issue-7479

Conversation

@sabaka-chabaka

@sabaka-chabaka sabaka-chabaka commented Nov 23, 2026 •

Copy link
Copy Markdown

Fixes #7479

Problem

With OpenAIResponsesChatClient in streaming mode, the ChatResponseUpdate
carrying a FunctionCallContent had MessageId == null. ToChatResponse()
then produced a ChatMessage without a MessageId, which differs from the
chat completions-based IChatClient and from the Responses client when no
function call is involved.

Cause

lastMessageId is only set when an output_item.added update is a
MessageResponseItem. For a FunctionCallResponseItem it is never set, so
the update created in the output_item.done handler had no id.

Fix

Pass the function call item's id when creating that update:

yield return CreateUpdate(
    OpenAIClientExtensions.ParseCallContent(...),
    messageId: fcri.Id);

Behavior change worth calling out

A stream of function_call → function_call_output → message now
coalesces into two ChatMessages rather than one:

  1. MessageId = fc_...: FunctionCallContent + FunctionResultContent
    (the result update has no id, so it joins the preceding message)
  2. MessageId = msg_...: the text

Previously the function call update had no id, so everything was merged
into a single message. I think the new shape is more faithful to the
service's item boundaries, but flagging it for reviewers.

Tests

  • Added StreamingResponseWithFunctionCall_PreservesMessageId.
  • Updated StreamingResponseWithFunctionCallOutput_YieldsFunctionResultContent
    to expect two messages with ids fc_001 / msg_001.
  • OpenAIResponseClientTests: 130/130 on net10.0.

Not covered

The workaround in the issue also assigns ids to reasoning updates
(StreamingResponseReasoningSummaryTextDeltaUpdate,
ReasoningResponseItem done). This PR only addresses the function call
case described in the title; reasoning updates are unchanged.

Microsoft Reviewers: Open in CodeFlow

…tClient

When streaming, the update produced for a completed function_call output
item had a null MessageId, because lastMessageId is only populated for
MessageResponseItem. As a result, ToChatResponse() produced a ChatMessage
with FunctionCallContent but no MessageId, unlike the chat completions
client and unlike the Responses client when the model returns only text.

Use the function call item's Id as the MessageId for that update.

Because function calls now carry their own item id, a streamed response
that interleaves a function call, its function_call_output, and a
subsequent assistant message is coalesced into two ChatMessages (one for
the function call + result, keyed by the function call id, and one for
the text message) instead of one. Update
StreamingResponseWithFunctionCallOutput_YieldsFunctionResultContent
accordingly and add StreamingResponseWithFunctionCall_PreservesMessageId.

Fixes dotnet#7479
@sabaka-chabaka
sabaka-chabaka requested a review from a team as a code owner November 23, 2026 22:46
@github-actions github-actions Bot added the area-ai Microsoft.Extensions.AI libraries label Nov 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-ai Microsoft.Extensions.AI libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAI Responses API streaming responses are missing MessageID on function calls.

1 participant