Skip to content

Commit a93ff7f

Browse files
Antriksh JainCopilot
andcommitted
feat(azure.ai.agents): align show non-Active branches with issue Azure#7975 vocabulary (P5.1 C5)
Fixes B8: `azd ai agent show` returned `monitor --tail 100` on failed status and a `show` re-check on empty status. Per issue Azure#7975 lines 208-214 the vocabulary is: IF status == "active" OR status == "idle": -> "azd ai agent invoke <agent> 'Hello!'" IF status == "failed" OR status == "": -> "azd ai agent monitor --follow" ELSE: -> "azd ai agent show <agent>" (transitional re-check) Three changes: 1. New `AgentVersionIdle = "idle"` constant in error_codes.go. The verified platform enum (see error_codes.go:64-71 doc) only emits `active` today, but the issue spec treats `idle` as a "ready" synonym. We add it defensively so a future API surface change wouldn't make this branch return the wrong suggestion. The Active branch's switch case now reads `case AgentVersionActive, AgentVersionIdle:`. 2. `AgentVersionFailed` switch arm now emits `azd ai agent monitor --follow` (was `--tail 100`). By the time `show` surfaces the failure, the interactive user wants to watch the live tail of the next reconcile attempt, not capture a fixed 100-line window. The pre-C5 `--tail 100` behavior is preserved in the *invoke*-failure paths (resolver.go:291,300; error_codes.go:143) — those are post-mortem inspections after a 5xx response and have different intent. 3. Empty status (`AgentStatus == ""`) is now combined with the Failed arm via `case AgentVersionFailed, "":`. The previous fall-through to the unknown/transitional `show` re-check masked the case where the platform genuinely had no status to report — the live log feed is the most useful next view when "we don't know yet". Genuinely unknown statuses (anything not in the AgentVersionStatus enum and not "") still fall through to the unknown branch, which emits an `azd ai agent show <svc>` re-check. Tests: - resolver_test.go TestResolveAfterShow table: bumped `Failed` case from `monitor --tail 100` → `monitor --follow`, added `Idle` row routing to invoke, flipped `empty status` row from re-check → `monitor --follow`. - show_test.go TestResolveNextStepFromSource_NonActiveBranches: bumped the `failed` row from `--tail 100` → `--follow`. Doc comment on `ResolveAfterShow` now includes the full status mapping table (single source of truth in the code). Scope: ~40 LoC + doc/test updates. Independent of C1-C4. Source of truth: issue Azure#7975 lines 207-214 + P5.1 commit plan C5. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ed57cd8 commit a93ff7f

4 files changed

Lines changed: 51 additions & 6 deletions

File tree

cli/azd/extensions/azure.ai.agents/internal/cmd/nextstep/error_codes.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ const (
6868
// Empirical verification: `azd ai agent show` returns "active" for a
6969
// ready agent. The design-spec table uses title-case for readability
7070
// only; the canonical surface is lowercase.
71+
//
72+
// One member of this type — AgentVersionIdle — is a defensive
73+
// synonym not currently observed in the platform's verified enum;
74+
// see its doc comment for rationale.
7175
type AgentVersionStatus string
7276

7377
const (
@@ -76,6 +80,12 @@ const (
7680
// AgentVersionActive indicates the deploy succeeded and the agent is
7781
// ready to receive invocations.
7882
AgentVersionActive AgentVersionStatus = "active"
83+
// AgentVersionIdle is a defensive synonym for "active" — the issue
84+
// #7975 spec lists `idle` alongside `active` as a "ready" state
85+
// (lines 208-209), although the platform's verified enum only emits
86+
// `active` today. Treat any `idle` value the API may surface in the
87+
// future the same as `active` (route to the invoke suggestion).
88+
AgentVersionIdle AgentVersionStatus = "idle"
7989
// AgentVersionFailed indicates the deploy failed; the error payload
8090
// carries the structured reason.
8191
AgentVersionFailed AgentVersionStatus = "failed"

cli/azd/extensions/azure.ai.agents/internal/cmd/nextstep/resolver.go

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,16 @@ func resolveInvokeFailure(_ *State, mode InvokeMode, _ string, failure *InvokeFa
317317
// successful `azd ai agent show`. Branches on State.AgentStatus per the
318318
// platform's `AgentVersionStatus` vocabulary.
319319
//
320+
// Status mapping (issue #7975 lines 208-214):
321+
// - active / idle → `azd ai agent invoke <svc> "Hello!"` (ready to test)
322+
// - creating → `azd ai agent monitor --type system --follow`
323+
// - failed / "" → `azd ai agent monitor --follow` (live log feed,
324+
// used to be `--tail 100` pre-C5; spec calls for `--follow` so
325+
// the user can watch the next reconcile attempt stream live)
326+
// - deleting / deleted → `azd deploy` (redeploy)
327+
// - anything else (transitional / genuinely unknown) → `azd ai agent
328+
// show <svc>` re-check
329+
//
320330
// serviceName is the azure.yaml service name. It is used end-to-end:
321331
// (1) to look up State.Services[].Protocol for the protocol-aware
322332
// payload, (2) as the positional in the suggested
@@ -339,7 +349,11 @@ func ResolveAfterShow(state *State, serviceName string) []Suggestion {
339349
}
340350

341351
switch AgentVersionStatus(state.AgentStatus) {
342-
case AgentVersionActive:
352+
case AgentVersionActive, AgentVersionIdle:
353+
// Issue #7975 line 208: `idle` is a defensive synonym for
354+
// `active`. The platform's verified enum only emits `active`
355+
// today, but if the API ever surfaces `idle` we treat it the
356+
// same — both mean "ready to invoke".
343357
protocol := ProtocolResponses
344358
if svc := findService(state, serviceName); svc != nil && svc.Protocol != "" {
345359
protocol = svc.Protocol
@@ -356,9 +370,28 @@ func ResolveAfterShow(state *State, serviceName string) []Suggestion {
356370
Priority: 10,
357371
}}
358372
case AgentVersionFailed:
373+
// Issue #7975 line 211: failed status maps to `monitor
374+
// --follow`. The historical `--tail 100` was useful for
375+
// one-shot CI inspection but the interactive default is the
376+
// live tail — by the time `show` surfaces the failure, the
377+
// user wants to watch the next reconcile attempt stream
378+
// rather than capture a fixed-size window.
359379
return []Suggestion{{
360-
Command: "azd ai agent monitor --tail 100",
361-
Description: "deploy failed — view the structured error and TSG link above",
380+
Command: "azd ai agent monitor --follow",
381+
Description: "stream agent logs to investigate the failure",
382+
Priority: 10,
383+
}}
384+
case "":
385+
// Issue #7975 line 210: empty status also routes to `monitor
386+
// --follow`, but the framing differs from the Failed arm —
387+
// here the platform simply hasn't reported a Status yet (the
388+
// `show` table even suppresses the Status row in this case;
389+
// see show.go printShowResultTable). The most useful next
390+
// view is the live log feed, but we don't presume a failure
391+
// occurred.
392+
return []Suggestion{{
393+
Command: "azd ai agent monitor --follow",
394+
Description: "stream agent logs — status has not been reported yet",
362395
Priority: 10,
363396
}}
364397
case AgentVersionDeleting, AgentVersionDeleted:

cli/azd/extensions/azure.ai.agents/internal/cmd/nextstep/resolver_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,11 +563,12 @@ func TestResolveAfterShow(t *testing.T) {
563563
wantCmdHas string
564564
}{
565565
{"Active without service in state → responses payload", AgentVersionActive, "echo", `azd ai agent invoke echo "Hello!"`},
566+
{"Idle (defensive synonym for Active) → invoke", AgentVersionIdle, "echo", `azd ai agent invoke echo "Hello!"`},
566567
{"Creating → monitor system", AgentVersionCreating, "echo", "azd ai agent monitor --type system --follow"},
567-
{"Failed → monitor tail", AgentVersionFailed, "echo", "azd ai agent monitor --tail 100"},
568+
{"Failed → monitor --follow", AgentVersionFailed, "echo", "azd ai agent monitor --follow"},
568569
{"Deleting → redeploy", AgentVersionDeleting, "echo", "azd deploy"},
569570
{"Deleted → redeploy", AgentVersionDeleted, "echo", "azd deploy"},
570-
{"empty status → re-check show", "", "echo", "azd ai agent show echo"},
571+
{"empty status → monitor --follow", "", "echo", "azd ai agent monitor --follow"},
571572
{"unknown status → re-check show", "Transitioning", "echo", "azd ai agent show echo"},
572573
{"unknown status without agent name → bare show", "Transitioning", "", "azd ai agent show"},
573574
}

cli/azd/extensions/azure.ai.agents/internal/cmd/show_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,8 @@ func TestResolveNextStepFromSource_NonActiveBranches(t *testing.T) {
450450
want string
451451
}{
452452
{"creating", "azd ai agent monitor --type system --follow"},
453-
{"failed", "azd ai agent monitor --tail 100"},
453+
{"failed", "azd ai agent monitor --follow"},
454+
{"", "azd ai agent monitor --follow"},
454455
{"deleting", "azd deploy"},
455456
{"deleted", "azd deploy"},
456457
}

0 commit comments

Comments
 (0)