Scope Response.Update AdditionalProperties by MessageID - #1133
PratikDhanave (PratikDhanave) wants to merge 1 commit into
Conversation
Response.Update copied an update's AdditionalProperties into BOTH the target message and the response, so message-scoped provider metadata leaked to the response level and response-scoped metadata leaked onto the current message. Scope them to the message when the update carries a MessageID and to the response otherwise, matching .NET's ChatResponseExtensions.ProcessUpdate (which Response.Update ports).
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Empty-message-ID round trips can misplace message-scoped properties on the response.
Review effort: Lite
Findings: None
What changed in this PR
Updates Response.Update to scope AdditionalProperties by MessageID, with regression tests for message- and response-level metadata.
Changes:
- Applies metadata to only the appropriate scope.
- Adds coverage for both scoping cases.
| File | Description |
|---|---|
agent/response.go |
Implements MessageID-based metadata scoping. |
agent/response_test.go |
Tests message- and response-level property behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Scope: user-visible behavior (bug fix; no exported API surface change) Changed Go contract: Upstream evidence reviewed: Result: aligned. The Go change makes No
|
Response.Updatecopiedupdate.AdditionalPropertiesinto both the target message'sAdditionalPropertiesand the response-levelAdditionalProperties. So message-scoped provider metadata (an update carrying aMessageID) leaked up to the response, and response-scoped metadata (an update with noMessageID) leaked onto whichever message was current — duplicated and mis-attributed versus .NET.Response.Updateis a direct port of M.E.AIChatResponseExtensions.ProcessUpdate, which scopes these either/or:Change
update.MessageID != "", and to the response only when it is empty.Test
TestResponse_Update_AdditionalPropertiesScopedByMessageID: with a MessageID the props land on the message and the response stays empty; without one they land on the response and the message stays empty. Both halves fail before the change (props on both), pass after. The existingTestResponse_Update_AdditionalProperties(always uses a MessageID, asserts the message side) still passes.