Skip to content

Prompt for existing Foundry project when agent manifest has no model resources#7589

Merged
JeffreyCA merged 7 commits intomainfrom
copilot/fix-agent-manifest-prompt
Apr 9, 2026
Merged

Prompt for existing Foundry project when agent manifest has no model resources#7589
JeffreyCA merged 7 commits intomainfrom
copilot/fix-agent-manifest-prompt

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

Fixes #7539

When azd ai agent init processes a manifest with no resources section (e.g. a hosted agent manifest with only name, description, metadata, and template), the init flow previously skipped the Foundry project selection prompt entirely — it only asked for subscription and location, meaning it would always create new resources.

This PR adds a "Use an existing Foundry project / Create a new Foundry Project" prompt to the no-model-resources path in configureModelChoice(), aligning it with both the code-first init flow and the --project-id path which already handle this correctly.

Changes

  • Foundry project prompt for resource-less manifests — When manifestHasModelResources() returns false and no --project-id is provided, users now see:

    image image

    Selecting "existing" calls ensureSubscriptionselectFoundryProject, with a graceful fallback to "create new" if no projects are found. Selecting "create new" preserves the original ensureSubscriptionAndLocation behavior.

  • Unit tests — Added table-driven tests for manifestHasModelResources covering: prompt agent, hosted with model resource, tool-only resources, no resources, nil resources, empty slice, and mixed resources.

  • Minor formatting fixes — Updated hyperlinks in ACR and App Insights connection prompts to use cyan matching our the style guide.

    image

Copilot AI changed the title [WIP] Fix agent manifest to prompt for existing Foundry project Prompt for existing Foundry project when agent manifest has no model resources Apr 8, 2026
Copilot AI requested a review from JeffreyCA April 8, 2026 22:16
@JeffreyCA JeffreyCA marked this pull request as ready for review April 8, 2026 23:17
Copilot AI review requested due to automatic review settings April 8, 2026 23:17
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

📋 Prioritization Note

Thanks for the contribution! The linked issue isn't in the current milestone yet.
Review may take a bit longer — reach out to @rajeshkamal5050 or @kristenwomack if you'd like to discuss prioritization.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes azd ai agent init behavior for agent manifests that omit the resources section by ensuring users can choose between reusing an existing Microsoft Foundry project or creating new resources (instead of always defaulting to new resource creation).

Changes:

  • Add a “Use an existing Foundry project / Create new resources” prompt when the manifest has no model resources and --project-id is not provided.
  • Add table-driven unit tests for manifestHasModelResources across common manifest/resource combinations.
  • Update the Application Insights connection prompt docs line to render as a hyperlink.

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/init.go Adds a Foundry project configuration prompt for resource-less manifests and routes to existing-project selection or new-resource provisioning.
cli/azd/extensions/azure.ai.agents/internal/cmd/init_test.go Adds coverage for manifestHasModelResources decision logic.
cli/azd/extensions/azure.ai.agents/internal/cmd/init_foundry_resources_helpers.go Updates App Insights docs display to use output.WithHyperlink.

@JeffreyCA JeffreyCA added the ext-agents azure.ai.agents extension label Apr 9, 2026
Copy link
Copy Markdown
Member

@jongio jongio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issues to address:

  • init.go:666 - subscription prompt says "to provision" in the "existing" path, but user just chose to use an existing project. Match the model-resources path convention and reference finding/selecting.

Otherwise clean. The new prompt flow mirrors the model-resources "existing" path correctly, error handling uses exterrors.FromPrompt, and tests cover manifestHasModelResources well.

Copilot AI and others added 5 commits April 9, 2026 16:26
When an agent manifest has no model resources and no --project-id flag,
prompt the user to choose between using an existing Foundry project or
creating new resources, instead of only asking for subscription + location.

This ensures hosted agents without model resources (like the echo-agent
example) can still be deployed to an existing Foundry project.

Agent-Logs-Url: https://github.com/Azure/azure-dev/sessions/c0ddc37f-ff73-4eb7-8cd7-b839d50b19b3

Co-authored-by: JeffreyCA <9157833+JeffreyCA@users.noreply.github.com>
@JeffreyCA JeffreyCA force-pushed the copilot/fix-agent-manifest-prompt branch from 5f96e56 to 1024f66 Compare April 9, 2026 16:28
Co-authored-by: John Miller <tharealjohn@gmail.com>
@JeffreyCA JeffreyCA requested a review from therealjohn April 9, 2026 16:59
Copy link
Copy Markdown
Member

@jongio jongio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. The new prompt flow for resource-less manifests correctly mirrors the model-resources "existing/new" path - same helpers, proper fallback when no project is found, and exterrors.FromPrompt for error handling (which is actually cleaner than the manual cancellation check in the model-resources path).

Tests for manifestHasModelResources cover the important cases well.

Two minor observations (non-blocking):

  • init.go:657-658: "Foundry project" (lowercase) vs "Foundry Project" (uppercase) across the two choice labels. The model-resources path uses lowercase consistently.
  • init.go:701: default: handles the "new" case - case "new": would be more explicit, matching the model-resources switch at line 775.

@JeffreyCA JeffreyCA enabled auto-merge (squash) April 9, 2026 20:45
@JeffreyCA JeffreyCA merged commit 8472f78 into main Apr 9, 2026
19 checks passed
Copy link
Copy Markdown
Member

@jongio jongio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean PR. The new prompt flow for resource-less manifests correctly mirrors the model-resources "existing/new" path - same helpers, proper fallback when no project is found, and exterrors.FromPrompt for error handling.

Two minor consistency notes (non-blocking):

  • init.go: default handles the "new" case; case "new": would match the model-resources switch style
  • init.go: defaultIdx vs defaultIndex naming

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.

init with an agent manifest in the directory does not prompt me to pick existing Foundry project

6 participants