Fix agents init --image azure.yaml output#8876
Conversation
d829670 to
5cf3a82
Compare
📋 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
Aligns the azd ai agent init --image flow with the unified azure.yaml service shape by persisting pre-built images on the service’s top-level image: field (instead of embedding them into the temporary agent manifest/inline agent properties), and fixes YAML omitempty behavior so non-empty osutil.ExpandableString values reliably round-trip through project.Save / AddService.
Changes:
- Write
--image(and manifest-carried image) to the generatedazure.yamlserviceimage:field and stop embedding it into the synthesized temporary manifest. - Fix YAML
omitemptyhandling forosutil.ExpandableStringby addingIsZero(). - Add/update regression tests to ensure service-level
image:is persisted and not duplicated in inline agent properties.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| cli/azd/pkg/project/project_test.go | Adds regression test ensuring a service image: survives project.Save to azure.yaml. |
| cli/azd/pkg/osutil/expandable_string.go | Implements IsZero() to make YAML omitempty behave correctly for ExpandableString. |
| cli/azd/extensions/azure.ai.agents/internal/project/service_target_agent.go | Updates guidance/log messaging to refer to the azure.yaml agent service rather than agent.yaml. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/init.go | Routes pre-built image persistence through azure.yaml service image: and removes embedding image into synthesized manifest/template. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/init_test.go | Updates tests for the new pre-built image behavior and adds a regression test for service-level image:. |
jongio
left a comment
There was a problem hiding this comment.
One comment on a doc-comment/code mismatch in shouldUsePreBuiltImage.
5cf3a82 to
b78387a
Compare
jongio
left a comment
There was a problem hiding this comment.
Re-reviewed against b78387a (force-push since prior review).
Verified the refactoring from mutation-based image handling (setImageOnTemplate + agentUsesPreBuiltImage) to the pure extractor preBuiltImageForInit. The flag-wins-over-manifest precedence is correct, and returning "" for nil/non-container manifests is safe since input validation happens earlier in the init flow. Removing the image from the synthesized temporary manifest correctly centralizes the image on the azure.yaml service config.
The ExpandableString.IsZero() addition enables proper YAML omitempty detection for the image: field during project.Save.
b78387a to
5a84bbb
Compare
There was a problem hiding this comment.
Re-reviewed against 5a84bbb (force-push since prior review at b78387a).
Verified the refactoring:
- setImageOnTemplate + agentUsesPreBuiltImage (mutation + query) replaced by preBuiltImageForInit (pure extractor). Flag-wins-over-manifest precedence is correct.
- Synthesized manifest no longer embeds the image. Confirmed in addToProject that containerDef (line 2946) is still used for AgentDefinitionToServiceProperties but ServiceConfig.Image now reads from preBuiltImage, preventing the image from leaking into inline agent properties.
- ExpandableString.IsZero() correctly delegates to Empty(), enabling YAML omitempty round-trip for the image field. The value receiver matches the existing method set.
- shouldUsePreBuiltImage doc comment now accurately describes the dual source (azure.yaml service field with legacy agent.yaml fallback).
- Test coverage: TestPreBuiltImageForInit covers flag precedence and trimming, TestAddToProjectPreBuiltImageWritesServiceImage verifies the image rides on ServiceConfig.Image (not additional properties), and TestServiceImageSavedToYaml covers the save/load round-trip.
Prior comments addressed: doc-comment mismatch fix, round-trip assertion added, captureStdout wrapping added.
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Adds a new 'Test coverage symmetry' section to go.instructions.md, sourced from recurring reviewer feedback across three PRs (#8883, #8874, #8876). Rule covers three patterns flagged by reviewers: - Symmetric prompt paths (subscription ↔ location: success/error/cancel) - Serialisation round-trip tests (save + reload, not just write direction) - Compound constraint interactions (step-alignment × max-capacity) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fixes #8878
Summary
azd ai agent init --imagealigned with the unifiedazure.yamlshape by writing the pre-built image to the agent service's top-levelimage:field.--imagevalue into the synthesized temporary agent manifest / generated agent definition path.omitemptyhandling forosutil.ExpandableStringso non-empty service fields such asimage:surviveproject.Save/ extensionAddService.ServiceConfig.Imageand is not carried in inline agent properties.azure.yamlagent service instead ofagent.yaml.