-
Notifications
You must be signed in to change notification settings - Fork 60
[dotnet-port-api] Add Response.ModelID #1156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,10 @@ type Response struct { | |
| // ID identifies this response. | ||
| ID string `json:",omitzero"` | ||
|
|
||
| // ModelID is the identifier of the model that produced this response, when | ||
| // the provider supplies it. It is empty otherwise. | ||
| ModelID string `json:",omitzero"` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Parity concern (unresolved from prior review): Upstream .NET and Python deliberately keep model identity on the lower-level chat-response contract and omit it from the agent-level response contract that Go's
Go has no chat-level response type distinct from |
||
|
|
||
| // ConversationID identifies conversation history retained after this response | ||
| // by the service or per-service-call history persistence. When nil, the response | ||
| // does not claim that its messages can be recovered from a retained conversation. | ||
|
|
@@ -157,6 +161,7 @@ func (resp *Response) ToUpdates() []*ResponseUpdate { | |
| AgentID: resp.AgentID, | ||
| MessageID: msg.ID, | ||
| ResponseID: resp.ID, | ||
| ModelID: resp.ModelID, | ||
|
|
||
| ConversationID: resp.ConversationID, | ||
| FinishReason: resp.FinishReason, | ||
| AuthorName: msg.AuthorName, | ||
|
|
@@ -166,11 +171,12 @@ func (resp *Response) ToUpdates() []*ResponseUpdate { | |
| }) | ||
| } | ||
|
|
||
| if hasAdditionalProperties || resp.ContinuationToken != "" { | ||
| if hasAdditionalProperties || resp.ContinuationToken != "" || resp.ModelID != "" { | ||
| extra := &ResponseUpdate{ | ||
| AdditionalProperties: resp.AdditionalProperties, | ||
| AgentID: resp.AgentID, | ||
| ResponseID: resp.ID, | ||
| ModelID: resp.ModelID, | ||
| ConversationID: resp.ConversationID, | ||
| ContinuationToken: resp.ContinuationToken, | ||
| CreatedAt: resp.CreatedAt, | ||
|
|
@@ -213,6 +219,7 @@ func (resp *Response) Update(update *ResponseUpdate) { | |
| // clear values already received for the response. | ||
| resp.AgentID = cmp.Or(update.AgentID, resp.AgentID) | ||
| resp.ID = cmp.Or(update.ResponseID, resp.ID) | ||
| resp.ModelID = cmp.Or(update.ModelID, resp.ModelID) | ||
| if update.ConversationID != nil { | ||
| resp.ConversationID = update.ConversationID | ||
| } | ||
|
|
@@ -310,6 +317,11 @@ type ResponseUpdate struct { | |
| // ResponseID identifies the response of which this update is a part. | ||
| ResponseID string | ||
|
|
||
| // ModelID is the identifier of the model that produced this update, when the | ||
| // provider supplies it. It is typically set on updates that carry provider | ||
| // response metadata. | ||
| ModelID string `json:",omitzero"` | ||
|
|
||
| // ConversationID identifies history retained by the service or per-service-call | ||
| // history persistence. Providers set it only when later requests can refer to that | ||
| // history instead of resending the messages. Nil means this update does not | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1120,6 +1120,7 @@ func responsesProcessResponse(resp *responses.Response, seqNum int64, yield func | |
|
|
||
| currentUpdate := &agent.ResponseUpdate{ | ||
| ResponseID: resp.ID, | ||
| ModelID: resp.Model, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ModelID is only propagated on non-streaming responses across three providers This PR populates
Upstream M.E.AI sets |
||
| FinishReason: finishReason, | ||
| CreatedAt: time.Unix(int64(resp.CreatedAt), 0), | ||
| Role: message.RoleAssistant, | ||
|
|
@@ -1141,6 +1142,7 @@ func responsesProcessResponse(resp *responses.Response, seqNum int64, yield func | |
| } | ||
| currentUpdate.MessageID = out.ID | ||
| currentUpdate.ResponseID = resp.ID | ||
| currentUpdate.ModelID = resp.Model | ||
| currentUpdate.FinishReason = finishReason | ||
| // Only set ContinuationToken if it's not empty | ||
| if contToken != "" { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR adds
ModelIDtoagent.Response/agent.ResponseUpdate(the Go equivalent of upstreamAgentResponse/AgentResponseUpdate, notChatResponse/ChatResponseUpdate). Upstream,ModelId/modelexists only on the lower-levelChatResponse/ChatResponseUpdatetypes:Microsoft.Agents.AI.Abstractions/AgentResponse.csandAgentResponseUpdate.cshave noModelIdproperty (properties areAgentId,ResponseId,ContinuationToken,CreatedAt,FinishReason,Usage,RawRepresentation,AdditionalProperties).ModelIdis folded only inAIAgentChatClient.CloneWithConversationIdonChatResponse(dotnet/src/Microsoft.Agents.AI/ChatClient/AIAgentChatClient.cs:368), and referenced inAgentResponseUpdateTests.ConstructorWithChatResponseUpdateRoundtrips(dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/AgentResponseUpdateTests.cs:42) as aChatResponseUpdatefield that is not asserted to roundtrip ontoAgentResponseUpdate.AgentResponse.__init__/AgentResponseUpdate.__init__(python/packages/core/agent_framework/_types.py:2848and:3134) take nomodel/model_idparameter, while the siblingChatResponse.__init__/ChatResponseUpdate.__init__(same file,:2449and:2735) do.So both upstream implementations deliberately keep model identity at the chat-client layer and omit it from the agent-level response contract. Adding
ModelIDunconditionally to Go'sagent.Response/ResponseUpdate(theAgentResponseanalog) is a divergence from that design, not merely an idiomatic Go difference — it's a new agent-level field neither upstream implementation exposes.Suggested resolution: either (a) confirm with maintainers this is an intentional Go-specific enhancement over the agent-level contract (and document that divergence), or (b) if a
ModelIDsurface is wanted, scope it to a chat-level type analogous toChatResponse/ChatResponseUpdateif/when Go introduces one, rather thanagent.Response.