Commit d1d213c
fix(azure.ai.agents): ResolveAfterInit suggests
After `azd ai agent init` with "Deploy new model(s) from the catalog",
the suggestion was wrongly:
Next: azd ai agent run -- start the agent locally
azd deploy -- when ready to deploy to Azure
even though provision had not run yet and the user has no agent to run
against (AZURE_AI_PROJECT_ENDPOINT empty, no Bicep outputs populated).
Root cause
==========
ResolveAfterInit's decision tree branched only on MissingInfraVars
(derived from `${AZURE_*}` references in agent.yaml). The notetaking
sample's agent.yaml has no such references, so the list stayed empty
and the resolver fell through to the "Otherwise → azd ai agent run"
branch. The new-models path stores its outputs (project endpoint,
model deployments) as azd env vars that aren't templated into
agent.yaml until provision runs, so there was no signal in the
existing tree.
Fix
===
Add `!state.HasProjectEndpoint` as the first condition. The project
endpoint is the canonical "provision finished" marker — it is set by
`azd provision` as a Bicep output, or by `azd ai agent init` when the
user selects "Use existing project". When empty, provision hasn't run
yet and `azd provision` is the correct next step regardless of whether
agent.yaml directly references any AZURE_* variables.
Decision tree after the fix:
!HasProjectEndpoint OR MissingInfraVars → azd provision
MissingManualVars → azd env set <key> <val>...
Otherwise → azd ai agent run
The MissingInfraVars branch is preserved for the post-provision
re-provision case (user adds a new ${AZURE_*} reference to agent.yaml
after the last provision run).
Affected call sites (no changes needed at the call sites)
=========================================================
- `init.go:1608` — the user-reported bug; now suggests `azd provision`.
- `doctor.go:243` — second production caller; the doctor only renders
Next: when all checks pass, so this path is reached only after the
user has fixed the AZURE_AI_PROJECT_ENDPOINT failure — at which
point HasProjectEndpoint=true and the existing "run locally"
branch fires correctly.
Tests
=====
resolver_test.go::TestResolveAfterInit updated:
- happy-path test now uses `&State{HasProjectEndpoint: true}` —
represents a truly post-provision state.
- new subtest "project endpoint not yet set → provision" pins
the new branch on a zero-value State (the user's repro).
- existing infra-vars subtest now also sets HasProjectEndpoint=true
so it specifically exercises the re-provision case.
- new subtest "project endpoint missing wins over manual vars"
confirms ordering — provision unblocks both infra outputs AND
manual var resolution, so it must come first.
resolver_test.go::TestResolveAfterInit_ManualVarsCapAtThree updated
to set HasProjectEndpoint=true (otherwise it would now hit the new
provision branch instead of testing the manual-vars cap).
Pre-flight
==========
- gofmt -s -w . clean
- go vet ./... clean
- go build ./... clean
- go test ./... -count=1 all green
- golangci-lint run ./internal/cmd/nextstep/... 0 issues
- cspell on resolver.go 0 issues
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>azd provision when project endpoint is unset1 parent f39e0ac commit d1d213c
2 files changed
Lines changed: 40 additions & 9 deletions
Lines changed: 13 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
38 | 48 | | |
39 | 49 | | |
40 | 50 | | |
| |||
48 | 58 | | |
49 | 59 | | |
50 | 60 | | |
51 | | - | |
| 61 | + | |
52 | 62 | | |
53 | 63 | | |
54 | 64 | | |
| |||
Lines changed: 27 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
| 25 | + | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
33 | 42 | | |
34 | 43 | | |
35 | 44 | | |
36 | 45 | | |
37 | 46 | | |
38 | 47 | | |
39 | | - | |
| 48 | + | |
| 49 | + | |
40 | 50 | | |
41 | 51 | | |
42 | 52 | | |
43 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
44 | 62 | | |
45 | 63 | | |
46 | 64 | | |
| |||
73 | 91 | | |
74 | 92 | | |
75 | 93 | | |
76 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
77 | 98 | | |
78 | 99 | | |
79 | 100 | | |
| |||
0 commit comments