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)
| if msg.AdditionalProperties == nil { | ||
| msg.AdditionalProperties = make(map[string]any) | ||
| // A response-level metadata update must not create an empty message. | ||
| if update.MessageID != "" || update.AuthorName != "" || update.Role != "" || len(update.Contents) > 0 || update.RawRepresentation != nil { |
|
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. 👍 |

Summary
Prevent response-level metadata updates from creating an empty assistant message when a response is converted with
ToUpdatesand collected again.Response.Updatenow creates or mutates message state only when an update carries message data. Continuation tokens and response-level additional properties still round-trip normally.Testing
go test ./...go test -race ./...go vet ./...go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest run