Skip to content

fix: warn when agent services share a Foundry agent name#8879

Merged
trangevi merged 2 commits into
mainfrom
hui/warn-duplicate-agent-services
Jun 30, 2026
Merged

fix: warn when agent services share a Foundry agent name#8879
trangevi merged 2 commits into
mainfrom
hui/warn-duplicate-agent-services

Conversation

@huimiu

@huimiu huimiu commented Jun 30, 2026

Copy link
Copy Markdown
Member

Fixes #8872

Problem

In an azure.yaml with multiple host: azure.ai.agent services, two or more services can carry the same agent name. Foundry uses the agent name as an agent's unique identifier, so deploying both services creates/updates the same Foundry agent — they silently overwrite each other, and azd gives no signal.

Example from the issue: services toolbox-agent-2 and toolbox-agent-4 both set name: toolbox-agent-2.

Change

azd deploy/azd up now emits a non-blocking warning when two or more azure.ai.agent services resolve to the same Foundry agent name, naming the colliding services so the user can give each a unique name. Deploy still proceeds.

  • findDuplicateAgentNames scans the azure.ai.agent services, resolves each via project.LoadAgentDefinition (covers the unified inline shape, the legacy config shape, and a legacy on-disk agent.yaml), groups the azure.yaml service keys by resolved agent name, and returns groups shared by ≥2 services (deterministically sorted). Services that aren't hosted agents, can't be resolved, or have an empty name are skipped.
  • warnDuplicateAgentNames prints one yellow warning per group to stderr via output.WithWarningFormat, matching the existing init / legacy-shape warning style.
  • Wired into predeployHandler behind a new duplicateAgentNameWarnOnce sync.Once, so the project-wide scan warns at most once per process even though the handler fires per agent service — mirroring the existing developerRBACOnce pattern.

Tests

TestFindDuplicateAgentNames covers: no services, unique names, the issue's two-service collision, a three-way collision, multiple groups sorted by agent name, and non-agent-host / unresolvable services being skipped, plus a nil-project case.

Validation

From cli/azd/extensions/azure.ai.agents: gofmt clean, go build ./..., go vet ./internal/cmd/, and the full internal/cmd test suite all pass.

Copilot AI review requested due to automatic review settings June 30, 2026 05:17
@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

Adds a deploy-time, non-blocking warning in the azure.ai.agents extension when multiple azure.ai.agent services in a project resolve to the same Foundry agent name, helping users avoid silent overwrites in Foundry.

Changes:

  • Scan azure.ai.agent services during pre-deploy to detect duplicate resolved Foundry agent names and emit a warning once per extension process.
  • Add unit tests covering duplicate grouping, deterministic sorting, and skip conditions.
  • Document the new warning behavior in the extension changelog.

Reviewed changes

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

File Description
cli/azd/extensions/azure.ai.agents/internal/cmd/listen.go Adds duplicate-agent-name detection and emits an advisory warning during predeploy (once per process).
cli/azd/extensions/azure.ai.agents/internal/cmd/listen_test.go Adds table-driven tests for duplicate detection and skip cases.
cli/azd/extensions/azure.ai.agents/CHANGELOG.md Notes the new warning behavior for azd deploy / azd up.

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/listen.go
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/listen.go
@github-actions github-actions Bot added the ext-agents azure.ai.agents extension label Jun 30, 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.

One convention item: the new sort.* calls can be switched to slices.Sort/slices.SortFunc to match the Go 1.26+ patterns used throughout this extension. See inline suggestion for the specific change.

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/listen.go
@huimiu huimiu changed the title feat: warn when agent services share a Foundry agent name fix: warn when agent services share a Foundry agent name Jun 30, 2026
@trangevi trangevi merged commit beb8a8f into main Jun 30, 2026
26 checks passed
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.

warn on duplicate agent services referencing the same agent name

4 participants