Skip to content

[ext-agents]: azd ai agent init -m <azure.yaml> should merge into an existing project's azure.yaml #8884

Description

@huimiu

Summary

Follow-up to #8798. The initial implementation (PR adopting a sample's unified azure.yaml via azd ai agent init -m) handles the fresh-project case: when the target directory has no azure.yaml, the sample's azure.yaml (and referenced files) is adopted as the project manifest via azd-core's native template adoption.

The existing-project case is not yet supported. When a project-root azure.yaml already exists and the user runs azd ai agent init -m <sample azure.yaml>, the command currently returns a clear, actionable error rather than merging.

Desired behavior

Fall back to today's "add to project" behavior: append the sample's agent service(s) (and any uses:-referenced azure.ai.project / azure.ai.connection / azure.ai.toolbox sibling services not already present) into the existing azure.yaml, copying each agent's project: source directory into the project. Resolve service-name collisions (reuse resolveCollisions), and skip siblings that already exist so dependencies still resolve.

Why it was split out

Correctly appending a unified azure.yaml's services into an existing project requires careful per-host service round-tripping through Project().AddService — e.g. uses: is carried in AdditionalProperties and wired separately in the manifest flow, and each Foundry host promotes a different set of fields. Getting this wrong can drop or duplicate keys in the written azure.yaml, and it's hard to verify without live gRPC. Splitting it keeps the primary fresh-project adoption shippable and well-tested.

Acceptance

  • azd ai agent init -m <sample azure.yaml> in a directory with an existing project azure.yaml appends the sample's agent service(s) + missing referenced siblings, copying source dirs, with collisions resolved.
  • The written azure.yaml round-trips cleanly (no dropped/duplicated keys; uses: preserved).
  • Tests cover the merge (including name collisions and already-present siblings).

Related

Metadata

Metadata

Assignees

Labels

area/projectProject config, project_manager, service_managerarea/schemaazure.yaml JSON schemasenhancementNew feature or improvementext-agentsazure.ai.agents extension

Fields

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions