Skip to content

Update agent models to match TypeSpec definition#8789

Open
trangevi wants to merge 3 commits into
mainfrom
trangevi/update-agent-models-typespec-sync
Open

Update agent models to match TypeSpec definition#8789
trangevi wants to merge 3 commits into
mainfrom
trangevi/update-agent-models-typespec-sync

Conversation

@trangevi

Copy link
Copy Markdown
Member

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 on AgentVersionObject but missing at the agent level)

AgentEndpoint -- added ProtocolConfiguration field and supporting types:

  • ProtocolConfiguration struct with per-protocol config pointers (activity, responses, a2a, mcp, invocations, invocations_ws)
  • ActivityProtocolConfiguration with EnableM365PublicEndpoint
  • Empty marker structs for the other protocols (matching the TypeSpec which reserves them for future fields)

Constants -- added AgentEndpointAuthSchemeBotServiceTenant to match the TypeSpec AgentEndpointAuthorizationSchemeType union.

Tests -- added two round-trip tests covering the new fields:

  • TestAgentObject_RoundTrip_AllFields
  • TestAgentEndpoint_ProtocolConfiguration_RoundTrip

Notes

  • AgentVersionObject was already aligned with TypeSpec -- no changes needed there.
  • The agent show command calls GetAgentVersion (returns AgentVersionObject), so its output is unaffected. The AgentObject changes benefit commands that use GetAgent (e.g., list).

Fixes: #8338

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>
Copilot AI review requested due to automatic review settings June 23, 2026 22:46
@github-actions

Copy link
Copy Markdown

📋 Prioritization Note

Thanks for the contribution! The linked issue isn't in the current milestone yet.
Thank you for logging this issue; our team is reviewing it. If you need urgent prioritization, tag @RickWinter and @kristenwomack to let us know.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 AgentObject fields (State, InstanceIdentity, Blueprint, BlueprintReference).
  • Added AgentEndpoint.ProtocolConfiguration and 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.

Comment thread cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_api/models.go Outdated
Comment thread cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_api/models.go Outdated
Comment thread cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_api/models_test.go Outdated
@github-actions github-actions Bot added the ext-agents azure.ai.agents extension label Jun 23, 2026
trangevi and others added 2 commits June 23, 2026 16:07
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 jongio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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{}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ext-agents azure.ai.agents extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

agent show needs to be updated with new typespec objects

4 participants