Skip to content

feat(agents): opinionated defaults for azd ai agent init -m#8426

Merged
trangevi merged 13 commits into
mainfrom
jw/init-opinionated-defaults
May 29, 2026
Merged

feat(agents): opinionated defaults for azd ai agent init -m#8426
trangevi merged 13 commits into
mainfrom
jw/init-opinionated-defaults

Conversation

@v1212
Copy link
Copy Markdown
Collaborator

@v1212 v1212 commented May 28, 2026

Fixes #8472

Summary

Streamlined azd ai agent init experience when driven by a manifest (via -m <url> or interactive template selection). Introduces opinionated defaults that auto-resolve several decisions to reduce interactive prompts for quickstart scenarios.

Trigger: userProvidedManifest is true when the init flow is driven by a manifest -- either explicitly via -m flag/positional argument, or when the user interactively selects a template that resolves to a manifest.

About the -m URL: The manifest URL comes from azd ai agent sample list --output json (fields: manifestUrl, initCommand), dynamically sourced from the centrally-managed template catalog at https://aka.ms/foundry-agents-samples. Users simply copy it from the catalog or quickstart docs.

This PR is a prototype for team review -- validates the approach and UX before progressing to full product feature.


Before vs After

Before: azd ai agent init -m <url> (8+ prompts)

\
? How would you like to deploy your agent?

Container Image (Docker)
Source Code (ZIP upload)
? Select resources (CPU and Memory) for your agent
0.5 cores, 1Gi memory
? Select a Foundry project to host your agent
Use an existing Foundry project
? Select an Azure subscription
My Subscription (xxxxxxxx-...)
? Select a Foundry project
my-project (canadacentral)
? Model 'gpt-4.1-mini' is specified in the agent manifest.
Use 'gpt-4.1-mini' (from manifest)
? Found 1 existing deployment matching gpt-4.1-mini.
gpt-4.1-mini
? Select resources (CPU and Memory)
0.5 cores, 1Gi memory
\\

After: azd ai agent init -m <url> (3 prompts)

\
Downloading agent template...
? Select an Azure subscription

My Subscription (xxxxxxxx-...)
? Select a Foundry project
my-project (canadacentral)
? Model 'gpt-4.1-mini' -- select action:
Use existing deployment 'gpt-4.1-mini' (version: 2025-04-14)
Deploy a new model
Skip this model (do not deploy)

AI agent definition added to your azd project successfully!
\\


Prompt Count Comparison

Scenario Before After Reduction
Existing project + 1 matching deployment 8 3 -5
Existing project + multiple deployments 8 3 -5
New project (no existing projects) 11-14 3 -8~11
init without -m (unchanged) 10-12 10-12 0

Auto-Resolution Logic

Step Current Behavior With manifest (this PR) Override
Deploy mode PROMPT: Container / Code Auto: container --deploy-mode code
Runtime PROMPT: select Auto-detect from project files --runtime <value>
Entry point PROMPT: enter path Auto-detect (app.py / Program.cs) --entry-point <path>
Container resources PROMPT: select tier Auto: smallest (0.5 cores, 1Gi) N/A
Model confirm PROMPT: Use from manifest? Auto-confirm N/A
Deployment match PROMPT: select from list PROMPT: Use/Change/Skip --no-prompt auto-selects first
No-match deployment PROMPT: Deploy new / Use different Auto: deploy new N/A

Key Design Decisions

  1. Default deploy mode is container (not code) -- safer/more universal default; users who want code deploy pass --deploy-mode code
  2. Model deployment always prompts Use/Change/Skip -- user should consciously choose which deployment to use (or skip/create new)
  3. Applies to all manifest-driven flows -- both -m <url> and interactive template selection
  4. Resolution precedence: explicit flag > !showCodeDeploy > userProvidedManifest > noPrompt > interactive
  5. No silent magic -- auto-resolved values are logged (visible with --debug)

Implementation

  • userProvidedManifest field on InitAction -- captured when manifest is provided via -m or template selection
  • promptDeployMode: auto-selects container when manifest-driven
  • promptCodeConfig: auto-detects runtime + entry point
  • populateContainerSettings: auto-selects smallest tier
  • getModelDetails: skips model confirmation prompt
  • getModelDeploymentDetails: shows Use/Change/Skip prompt (no silent auto-select); auto-deploys-new when no match found
  • parseGitHubUrlNaive: refactored from method to package-level function (per review feedback)

Testing

  • All existing unit tests pass (13/13: TestPromptDeployMode_FlagOverride x5 + TestPromptCodeConfig_FlagOverrides x8)
  • 6 new test cases for promptDeployMode and promptCodeConfig
  • 356 lines of new tests for agent name resolution and manifest path handling (init_test.go)

E2E Test Results (2026-05-29, North Central US)

Tested on branch pr8426-latest with Foundry project wujia-aifproject-260527. All agents deployed and invoked successfully.

# Scenario Prompts Before Prompts After Reduction Init Deploy Invoke Result
1 Python -m + --project-id 8-12 0 -8~12 OK OK (container, v6) OK PASS
2 C# -m + --project-id 8-12 0 -8~12 OK OK (container, v2) OK PASS
3 -m without --project-id (interactive) 8-12 2-4 -6~8 OK OK (container, v1) OK PASS
5 -m + --project-id + --deploy-mode code --runtime --entry-point 8-12 0 -8~12 OK OK (code ZIP, v7) OK PASS
6 No -m flag (unchanged) 8-12 8-12 0 No regression PASS

When users provide a manifest explicitly via -m flag or positional argument,
apply opinionated defaults to minimize interactive prompts:

- Deploy mode: auto-select 'code' for Python/.NET projects
- Runtime: auto-detect from project files (requirements.txt  python_3_13,
  .csproj  dotnet_10)
- Entry point: auto-detect using existing detectDefaultEntryPoint logic
- Dependencies: default to remote_build
- Model confirmation: skip 'Use from manifest / Choose different' prompt
- Model deployment: auto-select if exactly one matching deployment exists
- Container resources: auto-select default tier (0.5 cores, 1Gi)

This reduces the -m quickstart from 8+ prompts to 2 (subscription + project).
All auto-resolved values are printed with a  prefix so users see what was chosen.

The existing interactive init (without -m) and --no-prompt mode are completely
unchanged. The userProvidedManifest bool is captured before auto-detection can
set manifestPointer, ensuring only explicit user intent triggers the
streamlined flow.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the ext-agents azure.ai.{agents,connections,inspector,projects,routines,skills,toolboxes} extensions label May 28, 2026
Jian Wu and others added 11 commits May 28, 2026 16:00
- Print ' Model: <name> (from manifest)' when skipping model confirm prompt
- Include version in deployment auto-select message for user clarity

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Auto-select 'deploy_new' when userProvidedManifest + no matching
  deployments (eliminates unnecessary prompt)
- Document resolution precedence in promptDeployMode comment
- Rename misleading test name to clarify what it actually tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…cope

- Print checkmark when auto-selecting deploy_new for no-match scenario
- Add comment explaining populateContainerSettings trigger conditions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
PR #8347 switched hosted-agent management calls from api-version=2025-11-15-preview
to api-version=v1. The preview API version had implicitly satisfied the Foundry
preview-feature gate, so requests went through without an opt-in header. The v1
endpoint enforces the gate explicitly: POST /agents/{name}/versions with
definition.kind=="hosted" now returns HTTP 403 preview_feature_required unless
the caller sends 'Foundry-Features: HostedAgents=V1Preview'.

Effect on users: 'azd deploy' fails for container (hosted) agents with the
preview_feature_required error returned from the Foundry API. Confirmed via
direct API probes against a live Foundry project: same URL/body/auth, only
the api-version and header differ.

  api-version=2025-11-15-preview, no header  -> 200 OK
  api-version=v1,                 no header  -> 403 preview_feature_required
  api-version=v1,                 with header -> 200 OK

Add the header inside CreateAgentVersion so all callers get the fix
(service_target_agent.go deployHostedAgent and cmd/optimize_deploy.go).

Scope: only CreateAgentVersion needs the change. Probed sibling v1 management
calls (GetAgent, GetAgentVersion, ListAgents, ListAgentVersions, PatchAgent)
against the same live project without the header - none returned 403. The
write path that creates a hosted resource is the only one currently gated.

Add a focused test that asserts CreateAgentVersion always sets the header,
so this can't silently regress again.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ilently auto-selecting

When `azd ai agent init -m <manifest>` selected a Foundry project that
already contained exactly one matching deployment for the manifest's
model resource, the code silently auto-selected that deployment with no
prompt. That made the model an invisible default and was inconsistent
with the Use/Change/Skip selector shown everywhere else.

This change replaces the silent path and the older
"Found N existing deployment(s)... Create new model deployment" selector
with a unified Use/Change/Skip-style prompt:

  - "Use existing deployment 'name' (version: X)" (one per matching
    deployment, sorted by name for deterministic ordering)
  - "Deploy a new model" (falls through to the existing deploy-new path
    which loads the model catalog)
  - "Skip this model (do not deploy)" (returns errModelSkipped; the
    resource is dropped from manifest.Resources by ProcessModels)

The selector uses stable `SelectChoice.Value` strings ("use:<name>",
"deploy_new", "skip") so behavior is keyed off values, not labels.

In `--no-prompt` mode the first sorted matching deployment is selected
automatically (no prompt) so headless/CI flows continue to work.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: trangevi <trangevi@microsoft.com>
@v1212 v1212 marked this pull request as ready for review May 29, 2026 02:06
Copilot AI review requested due to automatic review settings May 29, 2026 02:06
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 prototypes a streamlined azd ai agent init -m <manifest> experience by introducing “opinionated defaults” that auto-resolve several decisions (deploy mode/config, model selection, container resources) to reduce interactive prompts for quickstart scenarios.

Changes:

  • Add userProvidedManifest plumbing through the init flow, plus manifest “peeking” helpers to derive agent/project folder naming earlier.
  • Adjust deploy-mode / code-config prompting behavior to support auto-resolution paths.
  • Refactor model deployment selection to be deterministic in --no-prompt, add “skip model” support, and update tests accordingly.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
cli/azd/extensions/azure.ai.agents/internal/cmd/init.go Adds manifest-peek + early agent-name resolution, threads userProvidedManifest, changes container tier prompting, and alters some stdout/log output behavior.
cli/azd/extensions/azure.ai.agents/internal/cmd/init_test.go Adds unit tests covering manifest peek + early agent-name resolution + manifest-path absolutization.
cli/azd/extensions/azure.ai.agents/internal/cmd/init_models.go Adds model-skip sentinel, refactors deployment selection UI, and adjusts model processing to drop skipped resources.
cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_code.go Extends deploy-mode and code-config prompting to accept userProvidedManifest and apply defaults.
cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_code_test.go Adds coverage for the new userProvidedManifest behavior in deploy-mode/code-config prompting.

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init.go
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init.go
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init.go
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_code.go
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_code.go
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init.go
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init.go
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_models.go
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_models.go
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_models.go
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init.go Outdated
…l function directly

Per review feedback (trangevi): the InitAction.parseGitHubUrlNaive()
method was just a passthrough to the package-level function. Remove
the wrapper and call the package-level function directly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 29, 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.

@trangevi
Copy link
Copy Markdown
Member

/check-enforcer override

@trangevi trangevi enabled auto-merge (squash) May 29, 2026 14:33
@trangevi trangevi merged commit 5d89dd7 into main May 29, 2026
28 of 31 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,connections,inspector,projects,routines,skills,toolboxes} extensions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streamline azd ai agent init with opinionated defaults for manifest-driven flows

4 participants