Skip to content

Update agent models to match TypeSpec definition#8789

Merged
trangevi merged 4 commits into
mainfrom
trangevi/update-agent-models-typespec-sync
Jun 25, 2026
Merged

Update agent models to match TypeSpec definition#8789
trangevi merged 4 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.

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/endpoint_show.go Outdated
jongio
jongio previously requested changes Jun 24, 2026

@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.

Two issues still blocking merge:

  1. resolveEndpointProtocols falls through to the deprecated Protocols field when ProtocolConfiguration is non-nil but empty ({}). A non-nil ProtocolConfiguration should be treated as authoritative, even if no protocols are enabled inside it. See inline comment for the fix.

  2. CI (golangci-lint) is still failing on gofmt formatting. The ProtocolConfiguration, AgentEndpoint, and AgentObject structs in models.go have manual space-padding for struct tag alignment. Run gofmt -s -w models.go to fix.

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/endpoint_show.go Outdated
- 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 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.

Incremental review of aca656b (since my prior review on 9d81a0c).

All three prior findings are addressed:

  1. gofmt alignment in ProtocolConfiguration, AgentEndpoint, and AgentObject structs is fixed.
  2. resolveEndpointProtocols now treats a non-nil ProtocolConfiguration as authoritative, returning immediately even when empty. This prevents the incorrect fallthrough to the deprecated Protocols field.
  3. Test case added for the empty-ProtocolConfiguration-with-populated-Protocols scenario, 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 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.

Verified the four commits in aca656b:

  1. resolveEndpointProtocols treats a non-nil ProtocolConfiguration as authoritative, returning immediately when empty instead of falling through to the deprecated Protocols field.
  2. Model additions (State, InstanceIdentity, Blueprint, BlueprintReference on AgentObject; ProtocolConfiguration on AgentEndpoint; BotServiceTenant auth scheme) match the TypeSpec and use omitempty for optional fields.
  3. Go initialism casing is correct (MCPProtocolConfiguration, InvocationsWSProtocolConfiguration).
  4. Test coverage includes round-trip tests for new model shapes and table-driven tests for protocol resolution, including the empty-ProtocolConfiguration-with-populated-Protocols edge case.

No new issues found. My prior CHANGES_REQUESTED is still active and needs to be cleared by a maintainer with approval rights.

@trangevi trangevi dismissed jongio’s stale review June 25, 2026 21:25

Dismissing "changes requested" status as requested in most recent comment

@trangevi trangevi merged commit e587e54 into main Jun 25, 2026
26 checks passed
@trangevi trangevi deleted the trangevi/update-agent-models-typespec-sync branch June 25, 2026 21:25
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