azure.ai.agents - filter out unsupported models and locations from init prompts#7415
azure.ai.agents - filter out unsupported models and locations from init prompts#7415JeffreyCA wants to merge 2 commits intoAzure:mainfrom
Conversation
f2eb552 to
ad084b5
Compare
There was a problem hiding this comment.
Pull request overview
Updates the azure.ai.agents extension init experience to avoid offering invalid Azure regions and AI models during azd ai agent init, and aligns the code-first init path with the manifest-based recovery behavior when deployment resolution can’t complete directly.
Changes:
- Filters AI model prompts/catalog to models with the
agentsV2capability. - Restricts location selection during init to a hardcoded “hosted agents supported regions” allow-list via
PromptLocationRequest.AllowedLocations. - Adjusts code-first init to fall back into the shared recovery flow when deployment candidate selection fails or can’t find a valid no-prompt capacity candidate.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| cli/azd/extensions/azure.ai.agents/internal/cmd/init.go | Adds agentsV2 capability constant used for filtering models. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/init_models.go | Applies capability-based model filtering and tweaks env location update behavior. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/init_locations.go | Introduces hardcoded hosted-agent supported region allow-list for init. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_code.go | Uses shared recovery flow when direct deployment resolution/candidate selection can’t complete. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/init_foundry_resources_helpers.go | Enforces allowed locations in ensureLocation, adds shared helpers for model filtering and deployment resolution. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/init_foundry_resources_helpers_test.go | Adds unit test for agentModelFilter. |
| cli/azd/extensions/azure.ai.agents/go.mod | Bumps azd dependency, adds local replace, and updates indirect deps. |
| cli/azd/extensions/azure.ai.agents/go.sum | Updates dependency checksums to match go.mod changes. |
| cli/azd/extensions/azure.ai.agents/extension.yaml | Raises required azd version to include needed host prompt features. |
| google.golang.org/protobuf v1.36.11 | ||
| gopkg.in/yaml.v3 v3.0.1 | ||
| ) | ||
|
|
There was a problem hiding this comment.
go.mod adds a replace github.com/azure/azure-dev/cli/azd => ../.. directive, but unlike some other extensions in this repo there’s no nearby comment explaining that this is for monorepo/CI local resolution. Adding a short comment (similar to extensions/azure.appservice/go.mod) would help future maintainers understand why this replace is intentionally committed and when it should be removed.
| // Use the local azd module when developing in the monorepo or running in CI. | |
| // Remove this replace when referencing a published azd module version. |
cli/azd/extensions/azure.ai.agents/internal/cmd/init_foundry_resources_helpers.go
Show resolved
Hide resolved
jongio
left a comment
There was a problem hiding this comment.
Filters models and locations for the agents init flow. Clean refactoring of deployment resolution into smaller functions.
Findings: 0 critical, 0 high, 2 medium, 2 low
Issues to address:
init_from_code.go:643- partial InitAction construction is fragile; nil-pointer risk if called methods evolveinit_foundry_resources_helpers_test.go:298- test coverage gaps for new helper functionsinit_foundry_resources_helpers.go:782- manual loop whereslices.ContainsFuncfitsinit_foundry_resources_helpers.go:865- doc comment stale after function rename
Note: The recovery paths in promptForModelLocationMismatch pass model.Locations as AllowedLocations rather than intersecting with supportedRegionsForInit(). Users in the recovery flow can pick a location where the model is available but the hosted agent platform is not supported.
cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_code.go
Outdated
Show resolved
Hide resolved
cli/azd/extensions/azure.ai.agents/internal/cmd/init_foundry_resources_helpers.go
Outdated
Show resolved
Hide resolved
cli/azd/extensions/azure.ai.agents/internal/cmd/init_foundry_resources_helpers.go
Show resolved
Hide resolved
cli/azd/extensions/azure.ai.agents/internal/cmd/init_foundry_resources_helpers_test.go
Show resolved
Hide resolved
jongio
left a comment
There was a problem hiding this comment.
Previous findings still apply. One more nit:
- init_models.go:78 -
errvariable shadow in updateEnvLocation else block
jongio
left a comment
There was a problem hiding this comment.
All previous findings addressed. The modelSelector extraction is clean - proper encapsulation, lazy init, clear doc comment. The supportedModelLocations intersection fixes the recovery-flow location gap. Tests are thorough with good edge coverage (nil, empty, case-insensitive, mutation safety).
One remaining item: merge conflicts need resolution before this can merge.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
856c623 to
4d5e22e
Compare
Resolves #7351
TODO
github.com/azure/azure-dev/cli/azdversion is published, updatego.modand removereplacestatement. More info: Add Go module versioning to ship SDK with CLI releases #7403allowed_locationstoPromptLocationand improve AI model capacity resolution #7397This PR builds on #7397 and updates the
azure.ai.agentsextension to filter out unsupported models (incompatible with agents) and locations from prompts duringazd ai agent init. Previously, the prompts would show all Azure locations and available models.The init flow now limits location selection to these regions via a hardcoded list (due to lack of API). It also filters model selection to ones with the
agentsV2capability so the extension only offers models that are valid for agent scenarios.This PR also brings the code-first init path in line with the manifest-based flow. When deployment resolution cannot complete directly for the selected model and location, the extension now falls back to the shared recovery flow instead of failing early, which gives users a clearer path to recover from model or region mismatches.
Screenshots