Surface the Copilot usage model in response metadata - #1115
PratikDhanave (PratikDhanave) wants to merge 2 commits into
Conversation
The usage handler never read AssistantUsageData.Model, so callers could not tell which model actually served the request. Surface it on AdditionalProperties["model"], matching the Python client.
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The change is small, targeted, and includes a regression test covering the new behavior.
Review effort: Lite
Findings: 1
What changed in this PR
This PR ensures the Copilot provider surfaces the actual model that served a request by copying AssistantUsageData.Model into response metadata (ResponseUpdate.AdditionalProperties["model"]), enabling callers to detect backend auto-selection or fallback behavior without introducing a new public API.
Changes:
- Populate
ResponseUpdate.AdditionalProperties["model"]fromAssistantUsageData.Modelwhen non-empty. - Add a unit test asserting the model value is present on the collected response’s
AdditionalProperties.
| File | Description |
|---|---|
| provider/copilotprovider/copilot.go | Adds propagation of the serving model into ResponseUpdate.AdditionalProperties. |
| provider/copilotprovider/copilot_test.go | Adds a regression test that verifies the model is surfaced via response metadata. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // Surface which model actually served the request, matching the Python | ||
| // client which carries it as additional_properties["model"]. | ||
| if data.Model != "" { | ||
| update.AdditionalProperties = map[string]any{"model": data.Model} | ||
| } |
This comment has been minimized.
This comment has been minimized.
Set the usage model into a lazily-initialized AdditionalProperties map so existing or future properties on the update are not overwritten.
|
Scope: user-visible behavior Changed Go contract: Upstream evidence reviewed:
Result: aligned. The Go change brings
|

The Copilot usage handler (
assistantUsageUpdate) never readAssistantUsageData.Model, so a caller could not tell which model actually served the request (relevant when the Copilot backend auto-selects or falls back to a different model).The Python client surfaces it as
additional_properties={"model": model}on both run paths.Change
assistantUsageUpdate, setAdditionalProperties["model"]fromdata.Modelwhen non-empty.AssistantUsageData.Modelexists in the pinned copilot SDK;ResponseUpdate.AdditionalPropertiesalready propagates to the collected response. No new public API.Test
TestConvertToAgentResponseUpdate_UsageEvent_SurfacesModel: a usage event withmodel:"gpt-5"now surfacesAdditionalProperties["model"] == "gpt-5". Fails before (empty), passes after.