fix: isolate hosted-agent deployments by environment - #9793
fix: isolate hosted-agent deployments by environment#9793Hui Miao (huimiu) wants to merge 8 commits into
Conversation
|
Azure Pipelines: Successfully started running 2 pipeline(s). 19 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
📋 Prioritization NoteThanks for the contribution! The linked issue isn't in the current milestone yet. |
|
Azure Pipelines: Successfully started running 5 pipeline(s). 22 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
Isolates hosted-agent model deployments per azd environment and reconciles them before Foundry provisioning.
Changes:
- Stores deployment tuples in environment variables with indexed references.
- Resolves and validates tuples during synthesis and provisioning.
- Expands schemas, documentation, and regression coverage.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
cli/azd/test/functional/ai_agents/ai_agent_recording_test.go |
Verifies generated environment references. |
cli/azd/extensions/azure.ai.projects/schemas/azure.ai.project.json |
Allows referenced capacities. |
cli/azd/extensions/azure.ai.projects/README.md |
Documents deployment environment keys. |
cli/azd/extensions/azure.ai.projects/internal/synthesis/synthesizer.go |
Resolves deployment references and capacities. |
cli/azd/extensions/azure.ai.projects/internal/synthesis/deployment_environment_test.go |
Tests synthesis behavior. |
cli/azd/extensions/azure.ai.projects/internal/provisioning/foundry_provisioning_provider.go |
Reconciles tuples before preview and deployment. |
cli/azd/extensions/azure.ai.projects/internal/provisioning/foundry_provisioning_provider_resolveenv_test.go |
Extends provisioning test stubs. |
cli/azd/extensions/azure.ai.projects/internal/provisioning/deployment_environment.go |
Implements tuple reconciliation. |
cli/azd/extensions/azure.ai.projects/internal/provisioning/deployment_environment_test.go |
Tests reconciliation and prompting. |
cli/azd/extensions/azure.ai.projects/internal/exterrors/codes.go |
Adds a deployment-environment error code. |
cli/azd/extensions/azure.ai.projects/internal/cmd/root.go |
Defers canonical resolution during preprovision. |
cli/azd/extensions/azure.ai.projects/internal/cmd/project_service_config.go |
Resolves lifecycle deployment metadata. |
cli/azd/extensions/azure.ai.projects/internal/cmd/project_service_config_test.go |
Tests lifecycle resolution. |
cli/azd/extensions/azure.ai.agents/schemas/Deployment.json |
Allows referenced capacities. |
cli/azd/extensions/azure.ai.agents/schemas/azure.ai.agent.json |
Updates agent capacity schema. |
cli/azd/extensions/azure.ai.agents/README.md |
Documents environment isolation. |
cli/azd/extensions/azure.ai.agents/internal/synthesis/synthesizer.go |
Mirrors deployment resolution logic. |
cli/azd/extensions/azure.ai.agents/internal/synthesis/deployment_environment_test.go |
Tests mirrored synthesis behavior. |
cli/azd/extensions/azure.ai.agents/internal/project/deployment_capacity_test.go |
Tests capacity-reference round trips. |
cli/azd/extensions/azure.ai.agents/internal/project/config.go |
Supports integer or referenced capacities. |
cli/azd/extensions/azure.ai.agents/internal/cmd/init.go |
Persists deployment configuration during init. |
cli/azd/extensions/azure.ai.agents/internal/cmd/init_models.go |
Generates indexed references. |
cli/azd/extensions/azure.ai.agents/internal/cmd/init_models_test.go |
Tests multi-environment model initialization. |
cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_code.go |
Persists code-init deployment tuples. |
cli/azd/extensions/azure.ai.agents/internal/cmd/init_adopt.go |
Persists adopted deployment tuples. |
cli/azd/extensions/azure.ai.agents/internal/cmd/deployment_environment.go |
Implements indexed tuple persistence. |
cli/azd/extensions/azure.ai.agents/internal/cmd/deployment_environment_test.go |
Tests persistence and adoption behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| "azureaiagent/internal/project" | ||
| ) | ||
|
|
||
| var deploymentEnvironmentReferencePattern = regexp.MustCompile(`^\$\{[A-Za-z_][A-Za-z0-9_]*\}$`) |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 27 out of 27 changed files in this pull request and generated 1 comment.
Suppressed comments (3)
Previously missed (2) — in code that hasn't changed since the last review.
cli/azd/extensions/azure.ai.projects/internal/provisioning/deployment_environment.go:508
- This quota-filtered lookup invalidates a tuple based only on remaining quota. After a deployment consumes its requested quota, a repeat
azd provisioncan see less than that capacity remaining and classify the unchanged deployment as stale, causing an unnecessary prompt or a headless failure. Account for the matching deployment's already-consumed capacity (or verify an exact existing deployment before applying the remaining-quota check).
Options: &azdext.AiModelDeploymentOptions{
Locations: []string{p.location},
Versions: []string{modelVersion},
Skus: []string{skuName},
Capacity: new(capacity),
cli/azd/extensions/azure.ai.projects/internal/provisioning/deployment_environment.go:560
- The real host reports no-prompt model/deployment selection with
AiErrorReasonInteractiveRequiredand messages such as “cannot prompt ... in non-interactive mode,” soIsPromptRequired(which only searches for “prompt required”) returns false. The tailored headless error path is therefore skipped in production even though the tests' synthetic error reaches it. Match the structured AI reason as well.
if exterrors.IsPromptRequired(err) {
cli/azd/extensions/azure.ai.agents/internal/cmd/deployment_environment.go:270
- Existing-only selections have
deploymentReferencesbut nomanagedIndices, so this returns an empty project deployment list while the agent manifest still contains${AZURE_AI_MODEL_DEPLOYMENT_NAME}. Afterazd env new, the Foundry provider sees no canonical project tuple to reconcile, and the agent is left with an unset deployment reference instead of being prompted as this PR intends. Preserve reconciliation metadata for existing-only selections without causing the existing deployment to become ARM-managed.
if len(deploymentReferences) == 0 {
return references, nil
}
managed := make([]project.Deployment, 0, len(managedIndices))
| nextIndex := 0 | ||
| for i, deployment := range deployments { | ||
| if canonical[i] { | ||
| references[i] = deployment | ||
| continue |
azure.ai.agents PR buildNote This is an unsigned development build. Install it only if you trust this PR. Install the extension: azd ext install "https://azuresdkartifacts.z5.web.core.windows.net/azd/extensions/pr/9793/azure-ai-agents.zip"
|
azure.ai.projects PR buildNote This is an unsigned development build. Install it only if you trust this PR. Install the extension: azd ext install "https://azuresdkartifacts.z5.web.core.windows.net/azd/extensions/pr/9793/azure-ai-projects.zip"
|
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Why
Hosted-agent deployment values were written directly into the manifest, so reusing that manifest in another azd environment could carry over a deployment name, model, region, or capacity that does not exist or is no longer available in the target subscription. This can result in confusing deployment failures, including insufficient quota errors.
This approach keeps generated manifests portable by storing concrete choices in each azd environment and resolving them only when needed. It validates the six related values as one tuple so provisioning never mixes stale values from one environment with a new model selection.
What changed
_2,_3, and later suffixes for additional deployments.Validation
go test ./...incli/azd/extensions/azure.ai.agentsgolangci-lint run ./...incli/azd/extensions/azure.ai.agentsgo test ./...incli/azd/extensions/azure.ai.projectsgolangci-lint run ./...incli/azd/extensions/azure.ai.projectsgo test -tags=record -run '^$' ./test/functional/ai_agentsincli/azdFixes: #7306