Repository navigation
[release/17.0] Fix aspire agent init --non-interactive with multiple AppHosts - #22269
Conversation
When no AppHost is saved in settings and several AppHosts exist under the working directory, agent init prompted for a selection even in non-interactive mode, which threw. Fall back to the working directory for skill-source settings instead, matching the no-AppHost case. Co-authored-by: Copilot App <[email protected]>
Assert success and multi-AppHost discovery instead of snapshotting generated config. Co-authored-by: Copilot App <[email protected]>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 22269Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 22269" |
Tests selector2 / 101 PR test projects · 4 PR jobs, from 2 changed files. Selected PR test projects (2 / 101)
Selected PR jobs (4)
How these were chosen — grouped by what changed📦 affected project 🧪 Job reasons
Selection computed for commit |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the fix restoring non-interactive initialization when multiple AppHosts are discovered.
No open issues 🎉
What changed in this PR
Fixes aspire agent init --non-interactive failing when multiple AppHosts are discovered, restoring unattended initialization after configurable skill sources introduced AppHost settings lookup.
Changes:
- Prompts for AppHost selection only when interactive input is supported; otherwise uses the working directory’s settings.
- Adds a regression test for non-interactive multi-AppHost initialization and updates the existing selection test to use an interactive host.
| File | Description |
|---|---|
| tests/Aspire.Cli.Tests/Commands/AgentInitCommandTests.cs | Adds non-interactive regression coverage and configures the selection test for interactive input. |
| src/Aspire.Cli/Commands/AgentInitCommand.cs | Guards AppHost selection prompts and falls back to the working directory without interactive input. |
Review effort: Balanced
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
acb94c2
into
release/17.0
|
✅ No documentation update needed. excluded → base_branch_is_release, title_release_prefix. Backport PR ( |
|
/backport to main |
|
Started backporting to |
Backport of #22269 to main /cc @ellahathaway ## Customer Impact ## Testing ## Risk ## Regression? --------- Co-authored-by: Ella Hathaway <[email protected]> Co-authored-by: Copilot App <[email protected]>
Description
aspire agent init --non-interactivefailed when the working directory contained more than one AppHost and no AppHost was saved in settings:The failure came from
AgentInitCommand.GetConfigurationDirectoryAsync, added in #21364. When the Aspire skill is selected (the default), agent init resolves a configuration directory so it can read skill-source settings. With two or more AppHost candidates it always prompted the user to pick one, and that prompt throws in non-interactive mode. Users could only work around it by running from a single AppHost folder or passing--skills none.Agent init only reads optional settings from the selected AppHost and has no
--apphostoption, so the command now prompts only when interactive input is supported. In non-interactive mode with multiple candidates, it falls back to the working directory, which matches what it already does when no AppHost is found.User-facing usage
From a folder that contains several AppHosts:
This now completes successfully and uses the working directory's settings instead of failing.
Validation
AgentInit_NonInteractive_WithMultipleAppHosts_Succeeds. It uses the real non-interactive host and console interaction service, and it asserts success and that multi-AppHost discovery ran. With the fix temporarily removed, it fails with the same "requires interactive input" error shown above.AgentInit_UsesConfiguredOrSelectedAppHostSettingsto use an interactive host, because the selection prompt now runs only in interactive mode.dotnet test --project tests\Aspire.Cli.Tests\Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class "*.AgentInitCommandTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true": passed (77/77).Fixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?