Skip to content

Keep AdditionalProperties on every Responses output message#510

Open
PratikDhanave wants to merge 6 commits into
microsoft:mainfrom
PratikDhanave:fix-openai-responses-additionalprops
Open

Keep AdditionalProperties on every Responses output message#510
PratikDhanave wants to merge 6 commits into
microsoft:mainfrom
PratikDhanave:fix-openai-responses-additionalprops

Conversation

@PratikDhanave

Copy link
Copy Markdown
Contributor

Summary

In the non-streaming Responses path (provider/openaiprovider/responses.go), when a response has more than one output message, currentUpdate is reset to a fresh &agent.ResponseUpdate{} for each message after the first. The per-message block then repopulates MessageID, ResponseID, FinishReason, ContinuationToken, RawRepresentation, Role, and CreatedAt — but not AdditionalProperties. So the second and later messages lose response-level properties such as EndUserId (from resp.User); only the first message (initialized at the top) and the aggregated response-level merge retain them.

Fix

Repopulate currentUpdate.AdditionalProperties = responsesPopulateAdditionalProperties(resp) in the per-message block, so every output message carries the response-level properties.

Public API

No exported symbols change.

Tests

Adds TestResponses_NonStreaming_AllMessagesKeepAdditionalProperties: a response with two output messages and a response-level "user". The second message's update reports an empty EndUserId before this change and the correct value after. (The existing EndUserId coverage only checked the aggregated resp.AdditionalProperties, which the response-level merge kept populated from the first message — masking the per-message drop.)

go test ./provider/openaiprovider passes; gofmt clean.

In the non-streaming Responses path, currentUpdate is reset to a fresh
&ResponseUpdate{} for each output message after the first, then its
MessageID/ResponseID/Role/etc. are repopulated — but AdditionalProperties
(e.g. EndUserId from resp.User) was not, so the second and later messages
lost it. Only the first message and the response-level merge retained it.

Repopulate AdditionalProperties per message from the response so every
message carries it.

Adds a test with two output messages and a response-level user; the second
message's update reports an empty EndUserId before this change and the
correct value after.
Copilot AI review requested due to automatic review settings July 16, 2026 08:41
@PratikDhanave
PratikDhanave requested a review from a team as a code owner July 16, 2026 08:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a correctness issue in the OpenAI Responses non-streaming processing path where response-level AdditionalProperties (e.g., EndUserId derived from resp.User) were dropped for the 2nd and later output messages due to currentUpdate being reset between messages.

Changes:

  • Repopulates currentUpdate.AdditionalProperties for each output message in the non-streaming Responses path.
  • Adds a regression test covering multi-message non-streaming responses to ensure every message update retains response-level properties.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
provider/openaiprovider/responses.go Ensures per-message ResponseUpdates retain response-level AdditionalProperties even after currentUpdate is reset between messages.
provider/openaiprovider/responses_additionalprops_test.go Adds a regression test asserting EndUserId is present on all message-bearing updates for a multi-message response.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread provider/openaiprovider/responses.go Outdated
Move the per-message AdditionalProperties repopulation into the
message-transition reset so it only runs when currentUpdate is reset,
rather than re-setting it on every message including the first.
Comment thread provider/openaiprovider/responses_additionalprops_test.go Outdated
Address review feedback: consolidate into the package's canonical test file.
@PratikDhanave
PratikDhanave force-pushed the fix-openai-responses-additionalprops branch from f4741b9 to cc4fa40 Compare July 17, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants