Keep AdditionalProperties on every Responses output message#510
Open
PratikDhanave wants to merge 6 commits into
Open
Keep AdditionalProperties on every Responses output message#510PratikDhanave wants to merge 6 commits into
PratikDhanave wants to merge 6 commits into
Conversation
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.
There was a problem hiding this comment.
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.AdditionalPropertiesfor 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.
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.
qmuntal
requested changes
Jul 16, 2026
Address review feedback: consolidate into the package's canonical test file.
PratikDhanave
force-pushed
the
fix-openai-responses-additionalprops
branch
from
July 17, 2026 09:54
f4741b9 to
cc4fa40
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In the non-streaming Responses path (
provider/openaiprovider/responses.go), when a response has more than one output message,currentUpdateis reset to a fresh&agent.ResponseUpdate{}for each message after the first. The per-message block then repopulatesMessageID,ResponseID,FinishReason,ContinuationToken,RawRepresentation,Role, andCreatedAt— but notAdditionalProperties. So the second and later messages lose response-level properties such asEndUserId(fromresp.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 emptyEndUserIdbefore this change and the correct value after. (The existingEndUserIdcoverage only checked the aggregatedresp.AdditionalProperties, which the response-level merge kept populated from the first message — masking the per-message drop.)go test ./provider/openaiproviderpasses; gofmt clean.