Skip to content

Commit ed57cd8

Browse files
Antriksh JainCopilot
andcommitted
feat(azure.ai.agents): add monitor --follow secondary after invoke --local success (P5.1 C4)
Fixes B7: `azd ai agent invoke --local` success previously emitted only a single `azd deploy` suggestion. Per issue Azure#7975 lines 168-181, the natural follow-up loop is "ship to Azure, then watch the live logs" — surface both commands in one block: Next: azd deploy -- deploy the agent to Azure azd ai agent monitor --follow -- view logs after deploying Rationale: by the time `invoke --local` returns success, the user has already provisioned (dependencies exist) and the agent itself works. The next loop is the deploy + verify dance, so the live-log feed is the right secondary. Also updates the deploy command's description from the conversational "the local invoke worked — ship it to Azure" to the spec-aligned "deploy the agent to Azure" so the description column stays functional rather than narrative. Renderer fit: PrintNext (used by invoke.go) caps at 2 lines, which exactly accommodates the new shape; no callsite change needed. The existing remote-success path already returned 2 suggestions (`show <agent>` + `monitor`), so this brings the local- and remote-success paths into structural parity. Scope: ~40 LoC + doc/test updates. Independent of C1-C3. Out of scope (issue Azure#7975 lines 183-191 multi-agent variant): The multi-agent local-invoke output uses an "After deploying:" prose subsection with per-agent invoke commands. That requires threading state into ResolveAfterInvoke (today's call site passes state=nil — see invoke.go:222 doc) and either a new Suggestion sub-type for the indented subsection or a layout change to PrintNext. Deferred to a follow-up commit. The single-agent project case — by far the common one — is fully covered by this change. Tests: - `TestResolveAfterInvoke_Success` / "local success → deploy + monitor" updated to assert the 2-Suggestion shape, both command strings, both descriptions, and that neither is Trailing. Source of truth: issue Azure#7975 lines 168-181, P5.1 commit plan C4. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 91c87a4 commit ed57cd8

2 files changed

Lines changed: 44 additions & 8 deletions

File tree

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

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ type InvokeFailure struct {
220220
// ResolveAfterInvoke produces the Next: block for a completed invoke.
221221
//
222222
// Success paths:
223-
// - InvokeLocal → `azd deploy` (the natural next step is to ship)
223+
// - InvokeLocal → `azd deploy` + `azd ai agent monitor --follow`
224+
// (the local invoke worked, so the next loop is "ship to Azure
225+
// then watch the live logs". Spec: issue #7975 lines 168-181.)
224226
// - InvokeRemote → `azd ai agent show <agent>` + monitor secondary
225227
//
226228
// Failure paths:
@@ -237,11 +239,24 @@ func ResolveAfterInvoke(state *State, mode InvokeMode, agentName string, failure
237239

238240
func resolveInvokeSuccess(mode InvokeMode, agentName string) []Suggestion {
239241
if mode == InvokeLocal {
240-
return []Suggestion{{
241-
Command: "azd deploy",
242-
Description: "the local invoke worked — ship it to Azure",
243-
Priority: 10,
244-
}}
242+
// Issue #7975 lines 168-181: local-invoke success has run to
243+
// completion against a local `azd ai agent run` process, so
244+
// the user has already provisioned (dependencies exist) and
245+
// the agent code itself works. The natural next step is to
246+
// ship to Azure with `azd deploy`, and once it's running
247+
// there, `monitor --follow` is the live-log feed.
248+
return []Suggestion{
249+
{
250+
Command: "azd deploy",
251+
Description: "deploy the agent to Azure",
252+
Priority: 10,
253+
},
254+
{
255+
Command: "azd ai agent monitor --follow",
256+
Description: "view logs after deploying",
257+
Priority: 20,
258+
},
259+
}
245260
}
246261

247262
primary := "azd ai agent show"

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

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,11 +463,32 @@ func TestResolveAfterRun_NilState(t *testing.T) {
463463
func TestResolveAfterInvoke_Success(t *testing.T) {
464464
t.Parallel()
465465

466-
t.Run("local success → ship it", func(t *testing.T) {
466+
t.Run("local success → deploy + monitor", func(t *testing.T) {
467467
t.Parallel()
468468
out := ResolveAfterInvoke(&State{}, InvokeLocal, "", nil)
469-
require.Len(t, out, 1)
469+
// Issue #7975 lines 168-181: local-invoke success surfaces
470+
// both `azd deploy` (ship to Azure) and the live-log monitor
471+
// follow-up (verify the deployed copy is healthy).
472+
require.Len(t, out, 2)
473+
470474
assert.Equal(t, "azd deploy", out[0].Command)
475+
assert.Equal(t, "deploy the agent to Azure", out[0].Description)
476+
assert.False(t, out[0].Trailing,
477+
"primary suggestion must not be Trailing")
478+
479+
assert.Equal(t, "azd ai agent monitor --follow", out[1].Command)
480+
assert.Equal(t, "view logs after deploying", out[1].Description)
481+
assert.False(t, out[1].Trailing,
482+
"secondary suggestion must not be Trailing")
483+
484+
// Priority ordering matters: PrintNext / PrintAllNext stable-sort
485+
// by Priority ascending, so the slice position alone does NOT
486+
// guarantee the rendered order. Locking priorities here prevents
487+
// a future edit from accidentally inverting the values and
488+
// making `monitor --follow` render before `azd deploy`. Mirrors
489+
// the failure-path pattern on the remote-failure test below.
490+
assert.Less(t, out[0].Priority, out[1].Priority,
491+
"deploy must sort before monitor --follow")
471492
})
472493

473494
t.Run("remote success with agent name → show <agent> + monitor", func(t *testing.T) {

0 commit comments

Comments
 (0)