Repository navigation
Avoid messages for response-only updates - #1127
Kirill (llirik0) wants to merge 2 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Message-only metadata can be lost during response round trips.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
What changed in this PR
Prevents response-only metadata updates from creating empty assistant messages during response round trips.
Changes:
- Gates message mutation on message-related update fields.
- Adds metadata round-trip tests.
| File | Description |
|---|---|
agent/response.go |
Updates response aggregation behavior. |
agent/response_test.go |
Tests metadata-only round trips. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Scope: user-visible behavior Changed Go contract: Upstream evidence reviewed:
Result: aligned. Go's new guard in
|
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Metadata-only updates can still produce empty assistant messages during collection; the agent-level path needs correction and regression coverage.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Resolved since last review (1)
|
Reviewed this closely since it touches the same Composition with #1133 (worth the maintainers knowing before merge order is decided). #1133 scopes
So they dont conflict, but whichever merges second will want a trivial rebase in the same block. No action needed here beyond awareness. Question — Question — the Nothing blocking from my perspective — the direction is correct and well-tested. 👍 |
2c0b680 to
fd164b1
Compare
fd164b1 to
8669b06
Compare
8669b06 to
5c92893
Compare
|
Rebased onto current main and resolved the conflicts. Thanks PratikDhanave (@PratikDhanave) for the detailed review. Raw-only updates are now explicitly response-level; regressions also cover lifecycle events arriving after a real OpenAI message, so inherited roles cannot leak lifecycle timestamps or raw payloads into that message. The ToUpdates assistant fallback is limited to otherwise unidentifiable metadata-only messages, with the collector-default rationale documented in code. The rebase preserves the MessageID-based AdditionalProperties scoping now present on main; #1133 is still open. Full tests, race tests, vet, and root/catalog lint pass. |
| if len(resp.Messages) == 0 { | ||
| extra.FinishReason = resp.FinishReason | ||
| extra.RawRepresentation = resp.RawRepresentation |
| } | ||
| update := newResponseUpdate(task, cloneMetadata(task.Metadata), string(task.ID), messageID, message.RoleAssistant, contents) | ||
| role := message.Role("") | ||
| if messageID != "" || len(contents) > 0 { |
| CreatedAt: time.Unix(int64(resp.CreatedAt), 0), | ||
| Role: message.RoleAssistant, | ||
| } |
| case responses.ResponseOutputItemDoneEvent: | ||
| // Create update for all output item done events | ||
| u = createUpdate(message.RoleAssistant, nil) | ||
| u = createUpdate("", nil) |

Summary
Prevent response-only metadata and provider lifecycle updates from creating or modifying messages when collected into a
Response.Response.Updatetreats raw-only provider payloads as response metadata, not as evidence of a message. Genuine message updates retain their raw payloads.Agent.setAuthordecorates only message-bearing updates. OpenAI, AG-UI, and A2A lifecycle paths avoid introducing message discriminators for response-only events.ToUpdatespreserves response metadata when no messages exist. Its assistant-role fallback is limited to otherwise unidentifiable metadata-only messages; it is justified by the collector's existing assistant default, not a claim of identical .NET serialization behavior.Rebase and #1133
Rebased onto
mainat1ac53ce01a1c3a715f9fa318c2b9564fbfedfbf2, resolving conflicts while retaining upstream ConversationID propagation and MessageID-based AdditionalProperties scoping. #1133 remains open; this update preserves the scoping already present on main rather than introducing a competing rule.Validation
On the updated candidate:
go test ./...go test -race ./...go vet ./...golangci-lint rungolangci-lint run --config ../.golangci.ymlgit diff --checkAll passed. The new post-message lifecycle regressions failed before the role-clearing fix and passed afterward.