Skip to content

fix(agents): update container deploy schema to use protocol_versions and container_configuration#8829

Merged
v1212 merged 3 commits into
mainfrom
fix/container-deploy-schema-update
Jun 28, 2026
Merged

fix(agents): update container deploy schema to use protocol_versions and container_configuration#8829
v1212 merged 3 commits into
mainfrom
fix/container-deploy-schema-update

Conversation

@v1212

@v1212 v1212 commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

Migrate container deploy API schema to match the latest service-side TypeSpec definition:

  • container_protocol_versionsprotocol_versions (unified with code deploy)
  • top-level imagecontainer_configuration.image

Reference

Schema change is documented in the official REST API reference:
https://learn.microsoft.com/en-us/azure/foundry/agents/how-to/deploy-hosted-agent?pivots=rest#create-an-agent

The documented create-agent payload uses:
json { "definition": { "kind": "hosted", "container_configuration": { "image": "myacr.azurecr.io/my-agent:v1" }, "protocol_versions": [ {"protocol": "responses", "version": "1.0.0"} ], "cpu": "1", "memory": "2Gi" } }

Changes

  • models.go: Added ContainerConfigurationAPI struct, updated HostedAgentDefinition to use protocol_versions (via struct tag) and container_configuration for container image. Removed custom MarshalJSON. Updated UnmarshalJSON for backward compat with legacy fields.
  • map.go: Container deploy path now populates ContainerConfiguration instead of bare Image.
  • optimize_deploy.go: normalizeProtocolVersions handles both new and legacy field names. Added normalizeContainerImage to migrate legacy top-level image on raw maps (service responses bypass UnmarshalJSON).
  • service_target_agent.go: Display code reads from ContainerConfiguration.Image with empty-string guard.
  • Tests: All updated and passing, including legacy unmarshal backward compat test.

Backward Compatibility

UnmarshalJSON still reads legacy API responses that use container_protocol_versions and top-level image, migrating them to the new schema in memory. The optimize-deploy path also normalizes raw definition maps via normalizeContainerImage and normalizeProtocolVersions.

Fixes #8828

…and container_configuration

Migrate container deploy API schema:
- container_protocol_versions -> protocol_versions (unified with code deploy)
- top-level image -> container_configuration.image

UnmarshalJSON maintains backward compatibility by reading legacy fields
(container_protocol_versions, top-level image) and migrating them to
the new schema.

Fixes #8828

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 26, 2026 07:04
@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

Updates the azure.ai.agents extension’s hosted/container agent wire schema to match the latest service TypeSpec by unifying protocol versions under protocol_versions and moving the container image under container_configuration.image, while keeping backward-compatible deserialization for legacy responses.

Changes:

  • Introduces ContainerConfigurationAPI and updates HostedAgentDefinition JSON serialization/deserialization to use protocol_versions + container_configuration (with legacy-field migration on unmarshal).
  • Updates container deploy request construction and display logic to read/write ContainerConfiguration.Image.
  • Updates unit tests to validate the new schema and legacy unmarshal behavior.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
cli/azd/extensions/azure.ai.agents/internal/project/service_target_agent.go Displays hosted agent image from ContainerConfiguration.Image.
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_yaml/map.go Builds container deploy requests using container_configuration.image.
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_yaml/map_test.go Updates assertions to validate container image is set via ContainerConfiguration.
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_api/models.go Adds ContainerConfigurationAPI, switches to protocol_versions, and migrates legacy fields on unmarshal.
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_api/models_test.go Updates schema expectations and adds a legacy-unmarshal test.
cli/azd/extensions/azure.ai.agents/internal/cmd/optimize_deploy.go Normalizes/migrates protocol versions to protocol_versions when cloning definitions.
cli/azd/extensions/azure.ai.agents/internal/cmd/optimize_deploy_test.go Updates optimize deploy definition tests for the new schema/migration behavior.

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

CI is failing: golangci-lint reports a gofmt error in optimize_deploy_test.go:124. The map literal in TestBuildDeployDefinition_NormalizesProtocolVersion mixes alignment styles (some keys padded, some not). Running gofmt -s -w . should fix it.

Beyond the formatting issue, one functional gap: normalizeProtocolVersions now migrates the legacy container_protocol_versions field to protocol_versions on raw maps, but there is no equivalent migration for the legacy top-level image field to container_configuration.image. Since AgentVersionObject.Definition is typed as any (line 299 of models.go), the service response is stored as a raw map[string]any that never passes through HostedAgentDefinition.UnmarshalJSON. If the service still returns the legacy schema, the optimize-deploy path will forward image unchanged in new version requests.

The overall approach (unifying to protocol_versions, removing custom MarshalJSON, adding backward-compat UnmarshalJSON) is solid and well-tested.

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/optimize_deploy_test.go Outdated
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/optimize_deploy.go
- Add normalizeContainerImage() to migrate legacy top-level 'image' to
  'container_configuration.image' on raw maps (optimize-deploy path)
- Guard displayAgentInfo against empty ContainerConfiguration.Image
- Use JSON map parsing in test instead of string.Contains for schema validation
- Add tests for normalizeContainerImage

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

My earlier inline concern about the optimize-deploy raw map path still applies: normalizeProtocolVersions migrates legacy container_protocol_versions to protocol_versions in buildDeployDefinition, but there is no equivalent for the legacy top-level image field to container_configuration.image. Since extractLatestDefinition produces a map[string]any (bypassing HostedAgentDefinition.UnmarshalJSON), any legacy image from the service response would pass through unchanged in new version requests.

If the service can still return old-schema responses for existing agent versions, consider adding a normalizeContainerConfiguration function alongside normalizeProtocolVersions. If the service has fully migrated all responses to the new schema, this can be safely ignored.

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

Comment isn't blocking, but something to consider in addition to Jon's comments

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

Update container deploy schema: migrate to protocol_versions and container_configuration.image

4 participants