Skip to content

Improve Copilot Cloud Sessions error handling and messaging#325196

Merged
osortega merged 1 commit into
mainfrom
osortega/agents/copilot-cloud-sessions-v2-backend
Jul 10, 2026
Merged

Improve Copilot Cloud Sessions error handling and messaging#325196
osortega merged 1 commit into
mainfrom
osortega/agents/copilot-cloud-sessions-v2-backend

Conversation

@osortega

@osortega osortega commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

This pull request enhances the error handling and messaging for the Copilot Cloud Sessions feature, specifically addressing how task states are communicated to users.

Changes Made:

  • Unified the error message format to Copilot stopped: <reason>, where <reason> is derived from the task state (e.g., "cancelled", "timed out", or specific error details).
  • Updated the formatTaskStoppedMessage function to reflect the new messaging format.
  • Cleaned up verbose diagnostic logging in the extractTaskErrorDetail function, removing unnecessary parameters and logs.
  • Restored assertions in the test for synthesizing a single turn that were accidentally removed in a previous edit.
  • Updated tests to match the new message format and ensure all scenarios are covered.

Rationale:

These changes improve user experience by providing clearer and more accurate feedback regarding task states, particularly distinguishing between cancellation and failure. The logging cleanup also enhances maintainability by reducing noise in the logs. All tests have been updated and pass successfully, ensuring the reliability of the new implementation.

Copilot AI review requested due to automatic review settings July 9, 2026 21:40

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.

Pull request overview

This PR improves error handling and messaging for the Copilot Cloud Sessions (Task API v2) feature. Previously, a task that terminally failed while its latest session state stayed in_progress/queued (e.g. "Failed to launch agent") would render a perpetual "Session is in progress…" spinner and cause the live streamer to poll forever. The change keys "is the task still running?" off the task-level state and surfaces a unified Copilot stopped: <reason> notice, where the reason is a concrete error detail when available, otherwise a state-derived word ("cancelled" / "timed out" / "an error occurred").

Changes:

  • Adds shared isActiveTaskState / isFailedTaskState helpers as the single source of truth for task-lifecycle state, replacing the local ACTIVE_STATES set in the streamer.
  • Introduces extractTaskErrorDetail and formatTaskStoppedMessage, and wires a terminal-stop notice into both the history builder and the live TaskTurnStreamer (with renderedError de-duplication).
  • Gates activeResponseCallback on the task-level active state so terminally-failed tasks don't stream/poll forever; updates and expands tests.
Show a summary per file
File Description
extensions/copilot/src/extension/chatSessions/vscode/copilotCodingAgentUtils.ts Adds isActiveTaskState/isFailedTaskState shared helpers for task-state classification.
extensions/copilot/src/extension/chatSessions/vscode-node/copilotCloudSessionContentBuilder.ts Adds extractTaskErrorDetail/formatTaskStoppedMessage; renders a stop notice instead of a stuck spinner in history.
extensions/copilot/src/extension/chatSessions/vscode-node/taskTurnStreamer.ts Settles the live stream on terminal task state and emits the stop notice; tracks renderedError to avoid duplicate detail.
extensions/copilot/src/extension/chatSessions/vscode-node/copilotCloudSessionsProvider.ts Gates the active-response streaming callback on isActiveTaskState(task.state).
extensions/copilot/src/extension/chatSessions/vscode-node/test/copilotCloudSessionsProvider.spec.ts Adds/updates tests for the new stopped-notice behavior and helper functions.

Review details

  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Medium

@osortega osortega marked this pull request as ready for review July 10, 2026 18:47
@osortega osortega enabled auto-merge (squash) July 10, 2026 18:56
@osortega osortega merged commit ce5e0c6 into main Jul 10, 2026
47 of 48 checks passed
@osortega osortega deleted the osortega/agents/copilot-cloud-sessions-v2-backend branch July 10, 2026 19:50
@vs-code-engineering vs-code-engineering Bot added this to the 1.129.0 milestone Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants