Update agent models to match TypeSpec definition#8789
Conversation
Add missing fields to AgentObject (State, InstanceIdentity, Blueprint, BlueprintReference), add ProtocolConfiguration type and field to AgentEndpoint, add BotServiceTenant auth scheme constant, and add per-protocol configuration types (Activity, Responses, A2A, MCP, Invocations, InvocationsWs). Fixes #8338 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
📋 Prioritization NoteThanks for the contribution! The linked issue isn't in the current milestone yet. |
There was a problem hiding this comment.
Pull request overview
This PR updates the azure.ai.agents extension’s Go agent API model structs to better match the Foundry service TypeSpec, preventing fields returned by the service from being silently dropped during JSON unmarshaling.
Changes:
- Added missing
AgentObjectfields (State,InstanceIdentity,Blueprint,BlueprintReference). - Added
AgentEndpoint.ProtocolConfigurationand per-protocol configuration types (including marker structs for future expansion). - Added round-trip JSON tests to cover the newly introduced fields.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_api/models.go | Extends agent/endpoint model structs with additional TypeSpec-aligned fields and protocol configuration types. |
| cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_api/models_test.go | Adds JSON round-trip tests validating the new fields serialize/deserialize correctly. |
Address PR review comments: rename McpProtocolConfiguration to MCPProtocolConfiguration and InvocationsWsProtocolConfiguration to InvocationsWSProtocolConfiguration to follow Go naming conventions for initialisms. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The deprecated Protocols field is replaced by ProtocolConfiguration in the TypeSpec. Update printEndpointTable to derive enabled protocols from ProtocolConfiguration keys (presence = enabled), falling back to the deprecated Protocols field for backward compatibility with older API responses. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jongio
left a comment
There was a problem hiding this comment.
Solid TypeSpec sync. The model additions are well-scoped, the resolveEndpointProtocols extraction is a clean refactor, and the round-trip tests cover the new shapes thoroughly. One CI fix needed before merge.
CI: golangci-lint is failing on gofmt. The ProtocolConfiguration and AgentEndpoint structs have manually-padded spaces aligning struct tags. Running gofmt -s -w models.go will fix it. Same likely applies to the AgentObject struct fields added in this PR.
| type ResponsesProtocolConfiguration struct{} | ||
|
|
||
| // A2AProtocolConfiguration describes configuration specific to the A2A protocol. | ||
| type A2AProtocolConfiguration struct{} |
There was a problem hiding this comment.
gofmt is flagging this struct (CI failure). The spaces between each type and its struct tag are manually padded for alignment, but gofmt expects tab-based alignment here. Run gofmt -s -w on this file to fix.
The same applies to the AgentEndpoint and AgentObject struct field blocks you reformatted below.
| if pc.InvocationsWS != nil { | ||
| protocols = append(protocols, "invocations_ws") | ||
| } | ||
| if len(protocols) > 0 { |
There was a problem hiding this comment.
When ProtocolConfiguration is non-nil but all fields are nil (e.g. the server returns "protocol_configuration": {}), this guard causes the function to fall through and surface the deprecated Protocols list. A non-nil pc should be treated as authoritative - return protocols even if empty, so older data doesn't silently override the new shape:
go if pc := endpoint.ProtocolConfiguration; pc != nil { // ... build list ... return protocols // return even if empty }
Motivation
Our Go agent model structs (
AgentObject,AgentEndpoint) were outdated compared to the service TypeSpec at azure-rest-api-specs. Missing fields meant the CLI silently dropped properties returned by the API.Changes
AgentObject-- added fields present in the TypeSpec but missing from Go:State(operational state: enabled/disabled)InstanceIdentity,Blueprint,BlueprintReference(identity/blueprint info already onAgentVersionObjectbut missing at the agent level)AgentEndpoint-- addedProtocolConfigurationfield and supporting types:ProtocolConfigurationstruct with per-protocol config pointers (activity, responses, a2a, mcp, invocations, invocations_ws)ActivityProtocolConfigurationwithEnableM365PublicEndpointConstants -- added
AgentEndpointAuthSchemeBotServiceTenantto match the TypeSpecAgentEndpointAuthorizationSchemeTypeunion.Tests -- added two round-trip tests covering the new fields:
TestAgentObject_RoundTrip_AllFieldsTestAgentEndpoint_ProtocolConfiguration_RoundTripNotes
AgentVersionObjectwas already aligned with TypeSpec -- no changes needed there.agent showcommand callsGetAgentVersion(returnsAgentVersionObject), so its output is unaffected. TheAgentObjectchanges benefit commands that useGetAgent(e.g., list).Fixes: #8338