Skip to content

feat(ai): add orthogonal Responses primitives - #9900

Draft
Wei Meng (m5i-work) wants to merge 8 commits into
mainfrom
m5i/9676-responses-primitives
Draft

feat(ai): add orthogonal Responses primitives#9900
Wei Meng (m5i-work) wants to merge 8 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

Replaces the workflow-oriented resumable Responses model with orthogonal CLI primitives that map directly to the service API.

  • keeps Response creation under azd ai agent invoke, with --background and --background --no-wait
  • adds azd ai agent responses show|follow|cancel
  • saves only the latest identified Response ID for implicit targeting
  • allows explicit --response-id targeting, including with --agent-endpoint, without changing current selection
  • removes cursor/status/session/conversation lifecycle state and periodic progress persistence introduced by feat(ai): add attached resumable Responses invoke #9703
  • makes responses follow one streaming GET that always replays from the beginning, with no cursor or automatic reconnect
  • does not block a new invoke when another Response is active; ordinary conversation reuse lets the service apply steering or concurrency behavior
  • rewrites the implementation specification around the protocol primitives

This is PR 1 of a new two-PR stack. A second PR will add matching Invocations show and cancel primitives without changing existing Invocation POST execution behavior.

Supersedes the Responses portions of #9704 and all steering-specific behavior in #9705.

CLI

azd ai agent invoke "message"
azd ai agent invoke "message" --background
azd ai agent invoke "message" --background --no-wait

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

Validation

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

  • go test ./...
  • go build ./...
  • go fix ./...
  • focused go test -race for the new Response state, command, stream, follow, and detach tests
  • command help smoke tests for responses, responses show, and invoke

golangci-lint and cspell were not available on the local PATH; CI runs both.

Fixes #9778

Part of #9676

@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
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/responses.go
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.

@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.6798092
  • Merge commit: 0b045df

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

2 participants