Keep AdditionalProperties on every Responses output message - #510
Conversation
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.
1ecf816 to
ca94710
Compare
|
Both review points are addressed: the tests were moved into |
ca94710 to
55fa7de
Compare
This comment has been minimized.
This comment has been minimized.
55fa7de to
1a154e1
Compare
This comment has been minimized.
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.
1a154e1 to
dd7e777
Compare
This comment has been minimized.
This comment has been minimized.
# Conflicts: # provider/openaiprovider/responses_test.go
This comment has been minimized.
This comment has been minimized.
|
Quim Muntal (@qmuntal) this one is ready for another look — both review points are addressed: the tests were moved into |
|
Thanks! Needs rebase. |
# Conflicts: # provider/openaiprovider/responses_test.go
Parity Review — PR #510Scope: Verdict: ✅ No parity issues. The SummaryThis PR fixes a bug in the Go-only non-streaming OpenAI Responses path where
No upstream Python or .NET changes are needed.
|
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.