Skip to content

Keep AdditionalProperties on every Responses output message - #510

Merged
Quim Muntal (qmuntal) merged 6 commits into
microsoft:mainfrom
PratikDhanaveFork:fix-openai-responses-additionalprops
Aug 24, 2026
Merged

Keep AdditionalProperties on every Responses output message#510
Quim Muntal (qmuntal) merged 6 commits into
microsoft:mainfrom
PratikDhanaveFork: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.

Copilot AI review requested due to automatic review settings July 16, 2026 08:41
@PratikDhanave
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
Contributor

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
Comment thread provider/openaiprovider/responses_additionalprops_test.go Outdated
@PratikDhanave
PratikDhanave (PratikDhanave) force-pushed the fix-openai-responses-additionalprops branch 2 times, most recently from 1ecf816 to ca94710 Compare July 23, 2026 08:44
@PratikDhanave

Copy link
Copy Markdown
Contributor Author

Both review points are addressed: the tests were moved into responses_test.go, and AdditionalProperties is now repopulated only in the per-message reset block (the first message keeps its initialized value, per the Copilot note). Rebased onto the latest main and green. Ready for another look whenever you have a moment — thanks!

@PratikDhanave
PratikDhanave (PratikDhanave) force-pushed the fix-openai-responses-additionalprops branch from ca94710 to 55fa7de Compare July 23, 2026 15:45
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added the parity-approved Go API consistency review found no parity issues label Jul 23, 2026
@PratikDhanave
PratikDhanave (PratikDhanave) force-pushed the fix-openai-responses-additionalprops branch from 55fa7de to 1a154e1 Compare July 24, 2026 01:43
@github-actions

This comment has been minimized.

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.
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.
Address review feedback: consolidate into the package's canonical test file.
@PratikDhanave
PratikDhanave (PratikDhanave) force-pushed the fix-openai-responses-additionalprops branch from 1a154e1 to dd7e777 Compare July 24, 2026 09:38
@github-actions

This comment has been minimized.

# Conflicts:
#	provider/openaiprovider/responses_test.go
@github-actions github-actions Bot added area:provider Changes files in the provider area area:provider/openai Changes files in the provider / openai area size:medium At most 100 changed lines across at most 5 files pending-auto-risk Automatic risk classification is in progress labels Aug 20, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added failed-auto-risk Automatic risk classification was inconclusive or failed and removed pending-auto-risk Automatic risk classification is in progress labels Aug 20, 2026
@PratikDhanave

Copy link
Copy Markdown
Contributor Author

Quim Muntal (@qmuntal) this one is ready for another look — both review points are addressed: the tests were moved into responses_test.go, and the AdditionalProperties repopulation was moved into the message-reset block so it only runs on a message transition (the first message keeps its initialized value). Functional CI is green. Thanks!

@qmuntal

Copy link
Copy Markdown
Member

Thanks! Needs rebase.

# Conflicts:
#	provider/openaiprovider/responses_test.go
@github-actions github-actions Bot added pending-auto-risk Automatic risk classification is in progress and removed failed-auto-risk Automatic risk classification was inconclusive or failed labels Aug 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Parity Review — PR #510

Scope: provider/openaiprovider/responses.go (bug fix, 2 files changed)

Verdict: ✅ No parity issues. The parity-approved label is retained.

Summary

This PR fixes a bug in the Go-only non-streaming OpenAI Responses path where currentUpdate.AdditionalProperties was not repopulated when iterating over multiple output messages, causing the second and later messages to silently lose response-level properties (e.g. EndUserId).

  • No exported symbols change. The fix is entirely within unexported provider-internal logic.
  • No new public API surface is introduced, so the public-api-change label is not warranted.
  • Cross-repo consistency: AdditionalProperties propagation on per-message updates is a Go-specific mapping layer over the OpenAI Responses API wire format. The upstream Python and .NET implementations do not have a direct equivalent for this multi-message iteration pattern; this is Go-internal bookkeeping with no parity obligation.
  • The added test (TestResponses_NonStreaming_AllMessagesKeepAdditionalProperties) correctly exercises the previously uncovered code path.

No upstream Python or .NET changes are needed.

Generated by Go API Consistency Review Agent · sonnet46 · 14.5 AIC · ⌖ 5.71 AIC · ⊞ 6K ·

@github-actions github-actions Bot added risk:medium Contained production impact requiring normal review depth and removed pending-auto-risk Automatic risk classification is in progress labels Aug 22, 2026
@qmuntal
Quim Muntal (qmuntal) added this pull request to the merge queue Aug 24, 2026
Merged via the queue into microsoft:main with commit 194dfac Aug 24, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:provider/openai Changes files in the provider / openai area area:provider Changes files in the provider area parity-approved Go API consistency review found no parity issues risk:medium Contained production impact requiring normal review depth size:medium At most 100 changed lines across at most 5 files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants