Skip to content

feat(ai): add unified invocation lifecycle commands - #9900

Merged
Wei Meng (m5i-work) merged 18 commits into
mainfrom
m5i/9676-responses-primitives
Sep 11, 2026
Merged

feat(ai): add unified invocation lifecycle commands#9900
Wei Meng (m5i-work) merged 18 commits into
mainfrom
m5i/9676-responses-primitives

Conversation

@m5i-work

@m5i-work Wei Meng (m5i-work) commented Sep 7, 2026

Copy link
Copy Markdown
Member

Summary

Implements the revised #9676 design: one invocations lifecycle command group across protocols, with --long-running controlling disconnect-independent execution and --no-wait controlling when the CLI returns.

  • replaces invoke --background / --resumable with invoke --long-running
  • adds shared invocations show|follow|cancel commands, initially backed by the Responses protocol
  • uses one --id selector and the same protocol inference rules as invoke; explicit --protocol selects a protocol, while --agent-endpoint identifies it from the URL
  • saves only the current Response ID and keeps explicit lifecycle operations from changing that selection
  • removes the public responses group; Responses lifecycle/identity/guidance, SSE, and store helpers are consolidated in invoke_response.go, while existing invoke implementations remain in invoke.go to minimize relocation-only diff
  • keeps invocations.go focused on shared command registration, resolution, validation, and dispatch
  • retains no cursors, starting_after, retries/reconnect loops, periodic persistence, active-work guards, dedicated steering, or legacy-state compatibility
  • keeps show JSON/table output consistent with sessions show
  • rejects unsupported protocol operations before issuing lifecycle requests

The service request still uses background=true for --long-running; the flag does not promise crash recovery or automatic reconnect. Follow makes one streaming GET and replays from the beginning. The tested service requires the original Response to have been created with background=true for follow; foreground snapshots can still be shown.

CLI

azd ai agent invoke "message"
azd ai agent invoke "message" --long-running
azd ai agent invoke "message" --long-running --no-wait

azd ai agent invocations show [--id <id>] [--protocol responses]
azd ai agent invocations follow [--id <id>] [--protocol responses]
azd ai agent invocations cancel [--id <id>] [--protocol responses]

Protocols are inferred when unambiguous. There are no compatibility aliases for the old command/flag forms.

Stack

Future protocols can implement suitable operations under the shared group; this does not add lifecycle support for A2A, Activity, WebSocket, or voice.

Validation

From cli/azd/extensions/azure.ai.agents:

  • go test ./...
  • go build ./...
  • go fix ./...
  • focused race tests for protocol/ID resolution, command validation, HTTP operations, SSE, and no-wait
  • scripted HTTP coverage verifies methods/headers, replay without retries, terminal cancellation fallback, and current-selection preservation

Earlier live tests against the supplied Responses reference agent validated create, detach, replay, steering via ordinary create, show, and cancellation; those transcripts use the previous command spelling. New command help/routing is covered by the updated tests.

Fixes #9778
Part of #9676
Supersedes #9704 and the dedicated steering design in #9705.

Interactive scenario coverage

Added offline Tier 0 scenarios under tests/cli-interactive-tester-scenarios/tier0/:

  • 0.17-invocations-help.yaml: group/subcommand discovery, selectors, and output formats
  • 0.18-invoke-long-running-validation.yaml: long-running/no-wait help and invalid combinations
  • 0.19-invocations-validation.yaml: unsupported operations, empty selectors, and removed flags

The root-help scenario now includes invocations; the extension-local tag taxonomy includes cmd:invocations. Shared PR impact mappings are deferred to #9996.

These scenarios were statically checked for YAML shape, tags, and placeholders and spell-checked. They were not executed through the interactive tester (MCP unavailable here). To run them, select foundry-extension-scenario-orchestrator and request only the relevant Tier 0 scenarios.

No new live/cloud scenarios, provisioning fixtures, profile requirements, or CI jobs were added. Existing Go HTTP tests cover lifecycle behavior; these scenarios deliberately cover the offline command surface only.

Approval boundary

This PR no longer changes .github/skills/foundry-extension-scenario-pr-regression/references/impact-mapping.md. All mapping additions and its line-ending cleanup are isolated in follow-up #9996, so separate .github/ owner approval does not block this feature PR.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
20 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Legacy-state repair guidance is incorrect, core HTTP lifecycle paths lack tests, and several added lines violate the enforced length limit.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Replaces workflow-oriented resumable Responses with direct create, show, follow, and cancel primitives.

Changes:

  • Adds background invocation with optional no-wait behavior.
  • Adds Responses lifecycle commands and in-memory reconnect cursors.
  • Simplifies persisted state to the latest Response ID.
File summaries
File Description
internal/exterrors/codes.go Updates Response error and operation codes.
internal/cmd/root.go Registers the Responses command group.
internal/cmd/responses.go Implements show, follow, and cancel.
internal/cmd/responses_test.go Tests command structure and formatting.
internal/cmd/listen.go Updates cleanup terminology.
internal/cmd/invoke.go Adds background and no-wait invocation.
internal/cmd/invoke_responses_stream.go Classifies interrupted streams for reconnect.
internal/cmd/invoke_response_store.go Simplifies state and supports legacy reads.
internal/cmd/invoke_response_store_test.go Tests simplified persistence.
internal/cmd/invoke_background.go Implements tracking and follow retries.
internal/cmd/invoke_background_test.go Tests background primitives.
internal/cmd/delete.go Updates cleanup terminology.
internal/cmd/agent_endpoint.go Builds lifecycle endpoint URLs.
docs/specs/long-running-agent-invoke.md Rewrites the protocol specification.
Review details

Suppressed comments (1)

cli/azd/extensions/azure.ai.agents/internal/cmd/responses.go:385

  • This line is 131 columns with tabs expanded to width 4, so the enabled lll check will reject it. Split the error construction to comply with the 125-column limit documented in cli/azd/AGENTS.md:115-126.
		return responseSnapshotResult{}, fmt.Errorf("Response snapshot ID %q does not match requested ID %q", actualID, responseID)
  • Files reviewed: 14/14 changed files
  • Comments generated: 4
  • Review effort level: Balanced

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/responses.go Outdated
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/responses.go Outdated
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/responses.go Outdated
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/responses_test.go Outdated
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

📋 Prioritization Note

Thanks for the contribution! The linked issue isn't in the current milestone yet.
Thank you for logging this issue; our team is reviewing it. If you need urgent prioritization, tag Rick Winter (@RickWinter) and Kristen Womack (@kristenwomack) to let us know.

@m5i-work
Wei Meng (m5i-work) marked this pull request as draft September 7, 2026 08:50
@m5i-work

Copy link
Copy Markdown
Member Author

Live E2E validation

Built and installed this stack with azd x build, then tested against the supplied longrun-responses-azd-cli-ref endpoint.

Passed:

  • foreground [fast] create completed all 3 steps and saved the Response ID
  • responses show --response-id ... --output table returned the completed snapshot
  • implicit responses show selected the saved current Response
  • --background --no-wait [slow] detached after saving and printing the Response ID
  • responses follow replayed buffered slow output and followed live events
  • a concurrent [fast] create reused the session/conversation, superseded the slow work, and completed all 3 replacement steps
  • following the completed background replacement replayed all 3 steps and exited 0
  • implicit responses cancel cancelled a detached slow Response
  • a repeated cancel remained successful
  • the cancelled snapshot reported cancelled

Observed service constraint:

  • following a foreground (background=false) Response returns HTTP 400: This response cannot be streamed because it was not created with background=true. Snapshot show still works. Background Response replay/follow works as designed.

@m5i-work

Copy link
Copy Markdown
Member Author

CI triage: the sole failed check on the previous head was live build 6797057. Its code-deploy scenario timed out after 30 activation polls with last status creating, before invoke ran; the container-deploy/invoke/down scenario passed. This is not a Responses lifecycle failure. Keeping the existing activation timeout and test assertions unchanged. The updated head has triggered fresh validation, including live build 6798093. Copilot triage is complete: obsolete legacy-state feedback resolved, low-cost line wrapping applied, and relevant lifecycle HTTP/selection tests added in 18506ae. Cursor/reconnect tests were intentionally not restored.

@m5i-work Wei Meng (m5i-work) changed the title feat(ai): add orthogonal Responses primitives feat(ai): add unified invocation lifecycle commands Sep 9, 2026
@m5i-work
Wei Meng (m5i-work) force-pushed the m5i/9676-responses-primitives branch from 88843c3 to 7ff11bc Compare September 10, 2026 05:35
@m5i-work
Wei Meng (m5i-work) marked this pull request as ready for review September 10, 2026 05:51
Copilot AI review requested due to automatic review settings September 10, 2026 05:51
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
20 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

JSON output can lose numeric precision, and the scenario impact mapping does not select the new lifecycle scenarios.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

cli/azd/extensions/azure.ai.agents/internal/cmd/invoke_response.go:339

  • Decoding the service payload into any converts JSON numbers to float64, so re-marshaling can corrupt valid values (for example, 9007199254740993 becomes 9007199254740992). Indent the validated raw JSON directly so --output json preserves the service response exactly.
  • Files reviewed: 21/21 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Copilot AI review requested due to automatic review settings September 11, 2026 01:37
@m5i-work
Wei Meng (m5i-work) force-pushed the m5i/9676-responses-primitives branch from a4ce85e to 5a516ff Compare September 11, 2026 01:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation matches the linked design and includes focused coverage for validation, persistence, streaming, and HTTP lifecycle behavior.

Review details
  • Files reviewed: 21/21 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@m5i-work

Copy link
Copy Markdown
Member Author

Final live invocation/regression check

Tested exact head 5a516ff, with an independently built main baseline at 57ca1f6 for regression comparisons. Both candidate core and extension were built from the PR checkout; private config copies isolated test state.

No newly introduced merge blocker observed in the tested invocation scope.

Live PASS:

  • Foreground Responses, session/conversation reuse and reset, explicit context IDs, input files, and raw output.
  • Attached/no-wait Responses; JSON/table show; repeat replay; implicit versus explicit ID selection; endpoint-only create/show/follow.
  • Interrupting follow leaves work active; cancel produces a cancelled snapshot; repeated cancel succeeds; unavailable replay fails usefully.
  • Same-conversation concurrent create/steering with the deterministic reference agent.
  • Existing Invocations 202 polling, session reuse, and raw initial/terminal output.
  • Existing explicit version/protocol and custom-header invocation, on both candidate and main.
  • Help/validation and feat(ai): add unified invocation lifecycle commands #9900's rejection of Invocations lifecycle operations (feat(ai): add Invocations protocol lifecycle support #9901 is not part of this test).

Additional focused HTTP/parser/raw/state/cleanup coverage passed under go test -race: 217 tests/subtests, zero failures.

Baseline investigation: stdin via --input-file - is unsupported on both builds; session lookup with a service alias fails on both, while the deployed agent name succeeds. Neither is introduced here. Initial harness wording/version-selection assumptions were corrected and the original failure evidence retained.

All test-created Responses were terminal; six test-created sessions were stopped. No shared agent or pre-existing session was stopped/deleted, and no infrastructure was provisioned or deployed. Temporary auth/config copies were removed.

Scope: real CLI checks against existing agents, not an execution of the interactive MCP scenario runner or the init→provision→deploy→down suite. No live A2A or model-memory claim. Raw local evidence is retained privately because it contains test resource identifiers. Existing CI/approval gates still apply.

@m5i-work

Copy link
Copy Markdown
Member Author

/check-enforcer override

@m5i-work
Wei Meng (m5i-work) merged commit daab689 into main Sep 11, 2026
20 of 32 checks passed
@azure-sdk-automation

Copy link
Copy Markdown
Contributor

azure.ai.agents PR build

Note

This is an unsigned development build. Install it only if you trust this PR.

Install the extension:

azd ext install "https://azuresdkartifacts.z5.web.core.windows.net/azd/extensions/pr/9900/azure-ai-agents.zip"
  • Version: 1.0.0-beta.14.pr.9900.6818575
  • Merge commit: 88e3423

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ext-agents azure.ai.agents extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reconnect to and cancel background Responses

4 participants