Commit 4569c55
feat(azure.ai.agents): pending-provision reasons foundation (4.11)
Introduces an extension-owned signal — `AI_AGENT_PENDING_PROVISION` —
that lists resource-class tags `azd ai agent init` configured but Azure
has not yet materialized. This is the architectural foundation for
fixing a class of "trailer suggests azd deploy but provision is
actually needed" bugs that surface when init flows create new
resources inside an otherwise-existing Foundry project.
This commit lands the plumbing only — no behavior change yet. Init
code paths that mark resources for provisioning, and the resolver's
consumption of the list, follow in subsequent commits (B = model
deployment, C = project tag, D = ACR + AppInsights).
Architecture
AI_AGENT_PENDING_PROVISION is a comma-separated, sorted,
deduplicated tag list. Empty/unset = nothing pending. Tag taxonomy
is open — readers (the resolver, doctor) only check for
non-emptiness, so new init sites can introduce new tags without
coordinating with this package.
Known tags today:
- project (will replace 4.10 NeedsAIProjectProvision)
- model_deployment (fixes the user-reported bug in commit B)
- acr (covered in commit D)
- app_insights (covered in commit D)
Lifecycle is explicit, unlike 4.10's USE_EXISTING_AI_PROJECT signal
derivation: init sites append tags as they decide; postprovision
clears the list. The resolver and doctor read the snapshot.
Components
internal/cmd/pending_provision.go (NEW, ~170 LoC)
Helpers for parsing/formatting/reading/writing the env var:
- parsePendingProvisionReasons(value)
- formatPendingProvisionReasons(reasons)
- addPendingProvisionReason(ctx, client, env, reason)
- removePendingProvisionReason(ctx, client, env, reason)
- clearPendingProvisionReasons(ctx, client, env)
- readPendingProvisionEnv(ctx, client, env) — NotFound-tolerant
- mutatePendingProvisionReasons(...) — shared RMW core
All write helpers are idempotent (skip the SetValue call when the
formatted value equals the prior on-disk value). Best-effort
parse normalization keeps the signal robust against hand edits.
internal/cmd/pending_provision_test.go (NEW)
Full coverage: parse edge cases, format normalization, add to
empty / append / duplicate-noop, remove existing / non-existent
/ from-unset, clear, and a round-trip sequence verifying
parse/format consistency end-to-end. Uses the existing
testEnvironmentServiceServer fixture pattern.
internal/cmd/listen.go (postprovisionHandler)
After the toolbox-provision loop completes successfully, if any
azure.ai.agent service was processed, fetch the current env name
via Environment().GetCurrent and call
clearPendingProvisionReasons. Best-effort: a transport failure
is logged but not returned, since user's provision DID succeed
and surfacing a clear-time error would be confusing. New helper
currentEnvName() factors out the GetCurrent dance.
internal/cmd/nextstep/state.go (assembleState)
Reads AI_AGENT_PENDING_PROVISION alongside the existing
USE_EXISTING_AI_PROJECT read, parses into the new
State.PendingProvisionReasons field via a local
parsePendingProvisionReasons copy (nextstep is a leaf package;
cannot import cmd). Transport errors increment errCount but do
not abort assembly — the field is best-effort and the resolver
tolerates an empty list.
internal/cmd/nextstep/types.go
New field State.PendingProvisionReasons with a doc comment
describing the signal contract and pointing back at
pending_provision.go for the canonical helpers.
internal/cmd/nextstep/resolver.go (ResolveAfterInit case 1)
OR-in `len(state.PendingProvisionReasons) > 0` so any non-empty
list fires the `azd provision` primary, regardless of whether
NeedsAIProjectProvision is set or AZURE_AI_PROJECT_ENDPOINT is
populated. Decision-tree doc comment updated. The legacy
NeedsAIProjectProvision branch is retained for backwards
compatibility — commit C will migrate init.go to write tags
directly and the field will be removed at that point.
Tests
Existing 4.10 sub-cases for NeedsAIProjectProvision stay green.
Three new state_test.go sub-cases lock the new field's parse
contract end-to-end (unset/single/multiple/malformed); the
transport-error tests bump errCount 3→4 and 4→5 to account for
the extra env read.
Two new resolver_test.go sub-cases pin the override behavior:
HasProjectEndpoint=true + PendingProvisionReasons non-empty must
still suggest `azd provision`, with both single-tag and
multi-tag inputs.
Pre-flight
gofmt -s -w . clean
go vet ./... clean
go build ./... clean
go test ./... green (cmd 13.9s, doctor 5.3s,
nextstep 4.9s, agent_api 9.2s, etc.)
golangci-lint run 0 issues
cspell 0 issues on changed production files
No behavior change yet — init.go, init_models.go, and
init_foundry_resources_helpers.go still drive their existing signals.
The resolver's case-1 condition is widened but no producer writes
PendingProvisionReasons in this commit; the empty list short-circuits
the OR, leaving identical behavior to 4.10.
Refs Azure#7975 (PR Azure#8057 design spec)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 874a516 commit 4569c55
8 files changed
Lines changed: 693 additions & 8 deletions
File tree
- cli/azd/extensions/azure.ai.agents/internal/cmd
- nextstep
Lines changed: 57 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
| 89 | + | |
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
| |||
94 | 96 | | |
95 | 97 | | |
96 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
97 | 138 | | |
98 | 139 | | |
99 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
100 | 157 | | |
101 | 158 | | |
102 | 159 | | |
| |||
Lines changed: 11 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
| 43 | + | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
62 | 67 | | |
63 | 68 | | |
64 | 69 | | |
| |||
94 | 99 | | |
95 | 100 | | |
96 | 101 | | |
97 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
98 | 106 | | |
99 | 107 | | |
100 | 108 | | |
| |||
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
94 | 123 | | |
95 | 124 | | |
96 | 125 | | |
| |||
Lines changed: 57 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
49 | 59 | | |
50 | 60 | | |
51 | 61 | | |
| |||
243 | 253 | | |
244 | 254 | | |
245 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
246 | 273 | | |
247 | 274 | | |
248 | 275 | | |
| |||
526 | 553 | | |
527 | 554 | | |
528 | 555 | | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
Lines changed: 59 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| 159 | + | |
159 | 160 | | |
160 | | - | |
161 | | - | |
162 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
163 | 164 | | |
164 | 165 | | |
165 | 166 | | |
| |||
223 | 224 | | |
224 | 225 | | |
225 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
226 | 280 | | |
227 | 281 | | |
228 | 282 | | |
| |||
899 | 953 | | |
900 | 954 | | |
901 | 955 | | |
902 | | - | |
903 | | - | |
| 956 | + | |
| 957 | + | |
904 | 958 | | |
905 | 959 | | |
906 | 960 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
83 | 89 | | |
84 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
85 | 111 | | |
86 | 112 | | |
87 | 113 | | |
| |||
0 commit comments