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.
jongio
left a comment
There was a problem hiding this comment.
Two issues still blocking merge:
-
resolveEndpointProtocolsfalls through to the deprecatedProtocolsfield whenProtocolConfigurationis non-nil but empty ({}). A non-nilProtocolConfigurationshould be treated as authoritative, even if no protocols are enabled inside it. See inline comment for the fix. -
CI (
golangci-lint) is still failing ongofmtformatting. TheProtocolConfiguration,AgentEndpoint, andAgentObjectstructs inmodels.gohave manual space-padding for struct tag alignment. Rungofmt -s -w models.goto fix.
- Run gofmt -s -w to fix space-padded struct tag alignment - Make non-nil ProtocolConfiguration authoritative even when empty, so it never falls through to the deprecated Protocols field - Add test case for empty ProtocolConfiguration with populated Protocols Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jongio
left a comment
There was a problem hiding this comment.
Incremental review of aca656b (since my prior review on 9d81a0c).
All three prior findings are addressed:
gofmtalignment inProtocolConfiguration,AgentEndpoint, andAgentObjectstructs is fixed.resolveEndpointProtocolsnow treats a non-nilProtocolConfigurationas authoritative, returning immediately even when empty. This prevents the incorrect fallthrough to the deprecatedProtocolsfield.- Test case added for the empty-
ProtocolConfiguration-with-populated-Protocolsscenario, confirming the authoritative behavior.
Lint and tests are passing. No new issues in the incremental diff.
Note: my prior CHANGES_REQUESTED verdict is still active on this PR. A maintainer with approval rights should clear it if the review is satisfactory.
jongio
left a comment
There was a problem hiding this comment.
Verified the four commits in aca656b:
resolveEndpointProtocolstreats a non-nilProtocolConfigurationas authoritative, returning immediately when empty instead of falling through to the deprecatedProtocolsfield.- Model additions (
State,InstanceIdentity,Blueprint,BlueprintReferenceonAgentObject;ProtocolConfigurationonAgentEndpoint;BotServiceTenantauth scheme) match the TypeSpec and useomitemptyfor optional fields. - Go initialism casing is correct (
MCPProtocolConfiguration,InvocationsWSProtocolConfiguration). - Test coverage includes round-trip tests for new model shapes and table-driven tests for protocol resolution, including the empty-
ProtocolConfiguration-with-populated-Protocolsedge case.
No new issues found. My prior CHANGES_REQUESTED is still active and needs to be cleared by a maintainer with approval rights.
Dismissing "changes requested" status as requested in most recent comment
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