Skip to content

fix(agents): resolve remote invoke name from inline service config#9114

Open
glharper wants to merge 1 commit into
mainfrom
glharper/9109-invoke-inline-agent-name
Open

fix(agents): resolve remote invoke name from inline service config#9114
glharper wants to merge 1 commit into
mainfrom
glharper/9109-invoke-inline-agent-name

Conversation

@glharper

Copy link
Copy Markdown
Member

What

Remote azd ai agent invoke failed after initializing a unified azure.yaml against an existing (brownfield) Foundry project, even though the azure.ai.agent service and its agent name were declared inline.

The command failed with the misleading fallback error that an agent name was required.

Root cause

resolveAgentServiceFromProject populated AgentServiceInfo.AgentName only from the deployed environment output:

AGENT_<SERVICE>_NAME

That output is written after deployment. Brownfield init writes the hosted-agent definition — including its name — inline on the azure.ai.agent service, but does not create the deploy output. Therefore explicit-protocol remote invoke (--protocol invocations in the repro) resolved the service successfully but left the target agent name empty.

Using the azure.yaml service key as a fallback would be unsafe because the service key and deployed agent name may intentionally differ.

Fix

  • Seed the resolved agent name from the inline/config-nested hosted-agent definition (project.AgentDefinitionFromService).
  • Continue reading AGENT_<SERVICE>_NAME; when present, it overrides the inline definition because it reflects the resource actually deployed.
  • Do not fall back to the service key.
  • Keep malformed/missing inline definitions best-effort so existing deployed projects with environment outputs are not regressed.

This lets remote invoke work immediately for the reported brownfield/unified configuration while preserving deployed-name precedence after azd deploy.

Tests

  • TestResolveAgentServiceFromProject_UsesInlineNameBeforeDeploy reproduces the issue: service key differs from the inline agent name and no AGENT_<SERVICE>_NAME exists. The inline name is resolved.
  • TestResolveAgentServiceFromProject_EnvironmentNameWins verifies deployed environment output remains authoritative when it differs from the inline definition.

Validation

  • go build ./...
  • go test ./... -count=1 (all extension packages)
  • go vet ./...
  • gofmt clean
  • golangci-lint run ./internal/cmd/... — 0 issues
  • cspell — 0 issues

No CHANGELOG.md entry is included; extension changelog entries are added during the release process.

Fixes #9109

Brownfield init against an existing Foundry project writes the hosted agent
name inline in the azure.ai.agent service, but does not populate the deployed
AGENT_<SERVICE>_NAME environment output. Remote invoke only consulted that env
value, so an otherwise valid unified azure.yaml service resolved with an empty
agent name and failed with the misleading "agent name is required" error.

Seed AgentServiceInfo.AgentName from the inline/config-nested hosted-agent
definition, then let AGENT_<SERVICE>_NAME override it after deployment. Do not
fall back to the azure.yaml service key because the service and deployed agent
names may intentionally differ.

Adds regression coverage for pre-deploy/brownfield inline-name resolution and
for deployed environment output retaining precedence.

Fixes #9109

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ea5e8124-350f-4420-b3dc-f88011b2aa74
Copilot AI review requested due to automatic review settings July 13, 2026 14:52
@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

Fixes brownfield remote agent invocation by resolving the deployed agent name from inline service configuration.

Changes:

  • Uses inline hosted-agent names before deployment outputs exist.
  • Preserves environment output precedence.
  • Adds regression tests for both resolution paths.

Reviewed changes

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

File Description
internal/cmd/helpers.go Adds inline agent-name fallback resolution.
internal/cmd/helpers_test.go Tests fallback and deployed-name precedence.

@github-actions github-actions Bot added the ext-agents azure.ai.agents extension label Jul 13, 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.

Verified the fix locally. Seeding the agent name from the inline hosted-agent definition before reading AGENT_<SERVICE>_NAME correctly fixes brownfield pre-deploy remote invoke, and the environment output still wins once it exists since it's applied after. All callers already guard on a non-empty AgentName, so no downstream regression. Both regression tests pass here.

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.

azure.ai.agents: remote invoke failed when init a manifest with existing Foundry project

3 participants