Commit 874a516
feat(extensions/azure.ai.agents): suggest
User-reported MVP bug: after `azd ai agent init` with "Deploy new
model(s) from the catalog", the trailer says `azd deploy` (or
`azd ai agent run`) instead of `azd provision`. The deploy-new path
needs `azd provision` first to create the Foundry project — running
locally or deploying without it cannot succeed.
Root cause: the post-init resolver uses `AZURE_AI_PROJECT_ENDPOINT`
as a "provision finished" marker. That marker is reliable on a green
field, but a stale endpoint value carried over from a prior init
run (existing-project path), or from a sibling azd environment that
already provisioned, leaves HasProjectEndpoint=true. With no missing
infra vars in the post-init agent.yaml, the resolver hits the default
branch and suggests `azd ai agent run` — misleading the user into
running a local invoke against a project that has not been provisioned.
Fix: add an explicit `NeedsAIProjectProvision` signal to nextstep.State.
The signal is driven by the existing `USE_EXISTING_AI_PROJECT` env var
that init.go already writes:
- init.go:976 → "false" when user picked "Deploy new model(s)"
- init.go:943 → "true" when user picked an existing Foundry project
- init.go:954, 881, 864 → "false" on existing-path fallbacks (no
project found, no matching models, etc.) — semantically equivalent
to "Deploy new" for the resolver's purposes.
assembleState now reads USE_EXISTING_AI_PROJECT alongside
AZURE_AI_PROJECT_ENDPOINT and sets NeedsAIProjectProvision=(value=="false").
Only the literal string "false" enables the flag; an unset variable
(no prior init) or "true" both leave it false, so existing-path
behavior is unchanged.
ResolveAfterInit's case 1 (the `azd provision` primary) now fires on
NeedsAIProjectProvision OR !HasProjectEndpoint OR MissingInfraVars.
This makes the deploy-new override explicit: when the user just
committed to creating a new Foundry project, suggest `azd provision`
regardless of any stale endpoint value lingering in the env.
Trade-off accepted: if the user re-runs `azd ai agent init` AFTER a
successful provision (when USE_EXISTING_AI_PROJECT=false persists in
the env), they'll see `azd provision` suggested again. Provision is
idempotent so this is harmless "false noise" rather than a broken
suggestion. A future refinement could use Bicep-output signatures
to distinguish post-provision from stale-endpoint, but that is out of
scope for the MVP bug fix.
Rejected alternatives:
- Tristate `*bool` field: gross to use in Go; the boolean default
correctly handles "unset" and "true" together.
- Clearing AZURE_AI_PROJECT_ENDPOINT at init.go:976: bigger blast
radius; affects downstream consumers beyond the resolver.
- Detecting "provision has run" via secondary Bicep outputs:
too template-specific.
Tests:
- state_test.go: 4 new sub-cases in TestAssembleState covering env
var unset / "true" / "false" / unrecognized value. Existing
transport-error tests updated for the new env read (errCount
bumped from 2→3 and 3→4 to match the additional read).
- resolver_test.go: 2 new sub-cases in TestResolveAfterInit
covering NeedsAIProjectProvision=true with stale endpoint
(override fires) and =false with endpoint set (legacy heuristic
drives — anti-regression case).
Pre-flight clean: gofmt, vet, build, full extension test suite green
(cmd 16.8s, nextstep 5.7s, doctor 4.5s, agent_api 10.8s, agent_yaml
1.5s, etc.), golangci-lint 0 issues, cspell 0 issues.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>azd provision after init's deploy-new path1 parent ce75211 commit 874a516
5 files changed
Lines changed: 156 additions & 7 deletions
File tree
- cli/azd/extensions/azure.ai.agents/internal/cmd/nextstep
Lines changed: 10 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
54 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
55 | 62 | | |
56 | 63 | | |
57 | 64 | | |
| |||
87 | 94 | | |
88 | 95 | | |
89 | 96 | | |
90 | | - | |
| 97 | + | |
91 | 98 | | |
92 | 99 | | |
93 | 100 | | |
| |||
Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
62 | 94 | | |
63 | 95 | | |
64 | 96 | | |
| |||
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
38 | 49 | | |
39 | 50 | | |
40 | 51 | | |
| |||
215 | 226 | | |
216 | 227 | | |
217 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
218 | 246 | | |
219 | 247 | | |
220 | 248 | | |
| |||
Lines changed: 69 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
158 | 224 | | |
159 | | - | |
160 | | - | |
161 | 225 | | |
162 | 226 | | |
163 | 227 | | |
| |||
834 | 898 | | |
835 | 899 | | |
836 | 900 | | |
837 | | - | |
838 | | - | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
839 | 904 | | |
840 | 905 | | |
841 | 906 | | |
| |||
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
68 | 85 | | |
69 | 86 | | |
70 | 87 | | |
| |||
0 commit comments