Skip to content

agentHost: recover failed Copilot turns in place - #332461

Draft
roblourens wants to merge 14 commits into
mainfrom
roblou/agents/vs-code-failed-turn-recovery
Draft

agentHost: recover failed Copilot turns in place#332461
roblourens wants to merge 14 commits into
mainfrom
roblou/agents/vs-code-failed-turn-recovery

Conversation

@roblourens

Copy link
Copy Markdown
Member

Summary

  • persist failures as durable error response parts and resume eligible Copilot failures in the same logical turn without adding another user message
  • add a Try Again affordance that dispatches chat/turnResume while preserving prior streamed output, errors, usage, and turn identity
  • restore interrupted/resumable turns across Agent Host restarts and harden resume against stale actions, duplicate requests, concurrent sends, and provider timing races
  • defer checkpoint finalization and queued-message admission while an error remains resumable, then finalize when the logical turn actually ends
  • preserve provider timing data when available and keep terminal actions race-safe when completion and failure signals arrive close together

Protocol dependency

Depends on microsoft/agent-host-protocol#390, which adds durable ErrorResponsePart state and the client-dispatchable chat/turnResume action.

Known protocol follow-ups remain unresolved: older supported AHP versions do not expose the new recovery shape, and AHP still lacks an independent terminal-event timestamp separate from provider duration/timing fields.

Validation

  • npm run typecheck-client
  • targeted Agent Host and Chat unit/UI suites: 1,593 passing, 16 pending
  • Copilot recovery E2E replays: 2 passing (resumes a failed turn in place; resumes the same turn after repeated failures)
  • npm run valid-layers-check
  • targeted ESLint on the final recovery delta
  • pre-commit hygiene: 352 files checked

(Written by Copilot)

roblourens and others added 11 commits August 21, 2026 14:21
Implement durable same-turn error recovery, zero-message Copilot continuation, race-safe server validation, restart restoration, and Try Again UI coverage.

(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

# Conflicts:
#	src/vs/platform/agentHost/common/agentService.ts
#	src/vs/platform/agentHost/node/agentService.ts
#	src/vs/platform/agentHost/node/agentSideEffects.ts
#	src/vs/platform/agentHost/node/codex/codexAgent.ts
#	src/vs/platform/agentHost/node/codex/codexReplayMapper.ts
#	src/vs/platform/agentHost/node/copilot/copilotAgent.ts
#	src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts
#	src/vs/platform/agentHost/node/copilot/mapSessionEvents.ts
#	src/vs/platform/agentHost/test/node/agentHostStateManager.test.ts
#	src/vs/platform/agentHost/test/node/agentService.test.ts
#	src/vs/platform/agentHost/test/node/agentSideEffects.test.ts
#	src/vs/platform/agentHost/test/node/claudeAgent.test.ts
#	src/vs/platform/agentHost/test/node/codex/codexReplayMapper.test.ts
#	src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts
#	src/vs/platform/agentHost/test/node/mapSessionEvents.test.ts
#	src/vs/platform/agentHost/test/node/mockAgent.ts
#	src/vs/platform/agentHost/test/node/reducers.test.ts
#	src/vs/platform/agentHost/test/node/serverIntegrationTestHelpers.ts
#	src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts
#	src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts
#	src/vs/workbench/contrib/chat/common/chatSessionsService.ts
(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…-failed-turn-recovery

# Conflicts:
#	src/vs/platform/agentHost/common/state/protocol/.ahp-version
#	src/vs/platform/agentHost/common/state/protocol/action-origin.generated.ts
#	src/vs/platform/agentHost/node/agentHostInputRequestTracker.ts
#	src/vs/platform/agentHost/node/claude/claudeCanUseTool.ts
#	src/vs/platform/agentHost/node/claude/claudeElicitation.ts
#	src/vs/platform/agentHost/node/codex/codexElicitationMapper.ts
#	src/vs/platform/agentHost/node/codex/codexUserInputMapper.ts
#	src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts
#	src/vs/platform/agentHost/test/node/agentHostInputRequestTracker.test.ts
#	src/vs/platform/agentHost/test/node/agentHostStateManager.test.ts
#	src/vs/platform/agentHost/test/node/agentSideEffects.test.ts
#	src/vs/platform/agentHost/test/node/claudeAgent.test.ts
#	src/vs/platform/agentHost/test/node/claudeElicitation.test.ts
#	src/vs/platform/agentHost/test/node/codex/codexElicitationMapper.test.ts
#	src/vs/platform/agentHost/test/node/codex/codexUserInputMapper.test.ts
#	src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts
#	src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts
Preserve the current Agent Host service graph and Copilot provider lifecycle while retaining same-turn continuation. (Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Retain failed-turn recovery on the latest Agent Host and chat service baseline. (Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Include the latest external-session default without changing recovery behavior. (Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Point the VS Code protocol snapshot at the commit that adds recovery support to the newly merged .NET client. (Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep retries on the original Agent Host participant, quarantine stale Copilot events across cancellation boundaries, and preserve checkpoint identity across resumable failures. Add focused unit, UI, multi-client, repeated-failure, and interruption E2E coverage. (Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Preserve durable same-turn error recovery while adapting to the Agent Host chat contributions refactor. (Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings August 25, 2026 00:42
Cover the durable error response part emitted when local errored conversations are imported into Agent Host sessions. (Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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

Adds durable Agent Host turn failures and in-place Copilot recovery through the existing chat UI.

Changes:

  • Adds ErrorResponsePart and chat/turnResume protocol support.
  • Adds Copilot resume handling, Try Again, and lifecycle safeguards.
  • Adds extensive unit, integration, and replay coverage.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/test/common/model/chatModel.test.ts Tests response reopening.
src/vs/workbench/contrib/chat/test/common/chatService/mockChatService.ts Updates resend mock signature.
src/vs/workbench/contrib/chat/test/common/chatService/chatService.test.ts Tests preserved resends and remote resume.
src/vs/workbench/contrib/chat/test/browser/widget/chatContentParts/chatErrorConfirmationPart.test.ts Tests Try Again interaction.
src/vs/workbench/contrib/chat/test/browser/agentSessions/stateToProgressAdapter.test.ts Tests durable error conversion.
src/vs/workbench/contrib/chat/test/browser/agentSessions/importLocalConversationToAgentSession.test.ts Updates imported-error assertions.
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts Tests resume UI and races.
src/vs/workbench/contrib/chat/common/model/chatModel.ts Adds response reopening support.
src/vs/workbench/contrib/chat/common/chatSessionsService.ts Marks resumed server requests.
src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts Preserves IDs during resend.
src/vs/workbench/contrib/chat/common/chatService/chatService.ts Extends resend APIs.
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatErrorConfirmationPart.ts Dispatches Try Again resends.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/stateToProgressAdapter.ts Maps durable errors to chat history.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/importLocalConversationToAgentSession.ts Imports errors as response parts.
src/vs/platform/agentHost/test/node/serverIntegrationTestHelpers.ts Adds crash-test helpers.
src/vs/platform/agentHost/test/node/reducers.test.ts Tests repeated resume reduction.
src/vs/platform/agentHost/test/node/protocol/turnExecution.integrationTest.ts Updates protocol error assertions.
src/vs/platform/agentHost/test/node/mockAgent.ts Emits durable mock errors.
src/vs/platform/agentHost/test/node/mapSessionEvents.test.ts Tests restoration and timing.
src/vs/platform/agentHost/test/node/e2e/suites/multiChatSuite.ts Updates E2E error handling.
src/vs/platform/agentHost/test/node/e2e/suites/coreSuite.ts Updates typed error assertions.
src/vs/platform/agentHost/test/node/e2e/suites/copilotCoverageSuite.ts Updates Copilot failure reporting.
src/vs/platform/agentHost/test/node/e2e/providers/copilotAgentHostE2E.integrationTest.ts Adds recovery E2E scenarios.
src/vs/platform/agentHost/test/node/e2e/providers/__snapshots__/Agent_Host_E2E___Copilot__Copilot-specific__resumes_a_failed_turn_in_place.traffic.ahp.yaml Records resume protocol traffic.
src/vs/platform/agentHost/test/node/e2e/KNOWN_ISSUES.md Documents record-only recovery coverage.
src/vs/platform/agentHost/test/node/e2e/harness/capiReplayProxy.ts Supports injected recording failures.
src/vs/platform/agentHost/test/node/e2e/harness/ahpSnapshot.ts Projects new protocol actions.
src/vs/platform/agentHost/test/node/e2e/harness/agentHostTarget.ts Propagates replay responses.
src/vs/platform/agentHost/test/node/e2e/harness/agentHostE2ETestHarness.ts Adds crash/restart and recording support.
src/vs/platform/agentHost/test/node/e2e/captures/copilotcli-resumes-the-same-turn-after-repeated-failures.yaml Records repeated-failure replay.
src/vs/platform/agentHost/test/node/e2e/captures/copilotcli-resumes-a-failed-turn-in-place.yaml Records single-resume replay.
src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts Tests provider continuation races.
src/vs/platform/agentHost/test/node/copilotAgent.test.ts Tests resume connection recovery.
src/vs/platform/agentHost/test/node/codex/codexReplayMapper.test.ts Updates Codex replay errors.
src/vs/platform/agentHost/test/node/codex/codexMapAppServerEvents.test.ts Updates Codex action expectations.
src/vs/platform/agentHost/test/node/claudeMapSessionEvents.test.ts Updates Claude error assertions.
src/vs/platform/agentHost/test/node/chatContributions.test.ts Tests resumable contribution behavior.
src/vs/platform/agentHost/test/node/agentService.test.ts Tests resume validation and aggregation.
src/vs/platform/agentHost/test/node/agentHostTurnTelemetry.test.ts Updates telemetry error actions.
src/vs/platform/agentHost/test/node/agentHostStateManager.test.ts Updates state-manager errors.
src/vs/platform/agentHost/test/node/agentHostInputRequestTracker.test.ts Clarifies a test name.
src/vs/platform/agentHost/node/copilot/mapSessionEvents.ts Restores interrupted resumable turns.
src/vs/platform/agentHost/node/copilot/copilotFailureTelemetry.ts Adds resume telemetry operation.
src/vs/platform/agentHost/node/copilot/copilotAgent.ts Implements provider resume routing.
src/vs/platform/agentHost/node/codex/codexReplayMapper.ts Persists Codex error parts.
src/vs/platform/agentHost/node/codex/codexMapAppServerEvents.ts Emits durable Codex errors.
src/vs/platform/agentHost/node/codex/codexAgent.ts Migrates Codex error actions.
src/vs/platform/agentHost/node/claude/claudeMapSessionEvents.ts Migrates Claude error actions.
src/vs/platform/agentHost/node/chatContributions/queueDrain/queueDrainContribution.ts Migrates queued-turn errors.
src/vs/platform/agentHost/node/chatContributions/checkpointAndChangeset/checkpointAndChangesetContribution.ts Defers resumable checkpoints.
src/vs/platform/agentHost/node/agentSideEffects.ts Routes resume and aggregates attempts.
src/vs/platform/agentHost/node/agentService.ts Validates resume dispatches.
src/vs/platform/agentHost/common/state/sessionState.ts Adds error and usage helpers.
src/vs/platform/agentHost/common/state/protocol/version/registry.ts Versions turn resume.
src/vs/platform/agentHost/common/state/protocol/common/notifications.ts Updates generated enum metadata.
src/vs/platform/agentHost/common/state/protocol/common/errors.ts Updates generated error contracts.
src/vs/platform/agentHost/common/state/protocol/common/commands.ts Updates generated command documentation.
src/vs/platform/agentHost/common/state/protocol/common/actions.ts Registers turn resume.
src/vs/platform/agentHost/common/state/protocol/channels-terminal/state.ts Updates generated enum metadata.
src/vs/platform/agentHost/common/state/protocol/channels-session/state.ts Updates generated session contracts.
src/vs/platform/agentHost/common/state/protocol/channels-session/commands.ts Updates generated enum metadata.
src/vs/platform/agentHost/common/state/protocol/channels-root/state.ts Updates generated enum metadata.
src/vs/platform/agentHost/common/state/protocol/channels-resource-watch/state.ts Updates generated enum metadata.
src/vs/platform/agentHost/common/state/protocol/channels-resource-watch/commands.ts Corrects generated documentation link.
src/vs/platform/agentHost/common/state/protocol/channels-chat/state.ts Defines durable error parts.
src/vs/platform/agentHost/common/state/protocol/channels-chat/reducer.ts Reopens resumable turns.
src/vs/platform/agentHost/common/state/protocol/channels-chat/commands.ts Updates generated enum metadata.
src/vs/platform/agentHost/common/state/protocol/channels-chat/actions.ts Defines turn-resume and error actions.
src/vs/platform/agentHost/common/state/protocol/channels-changeset/state.ts Updates generated enum metadata.
src/vs/platform/agentHost/common/state/protocol/channels-changeset/commands.ts Updates generated enum metadata.
src/vs/platform/agentHost/common/state/protocol/channels-automation/state.ts Updates generated enum metadata.
src/vs/platform/agentHost/common/state/protocol/channels-automation-run/state.ts Updates generated enum metadata.
src/vs/platform/agentHost/common/state/protocol/action-origin.generated.ts Marks resume client-dispatchable.
src/vs/platform/agentHost/common/state/protocol/.ahp-version Pins the protocol dependency.
src/vs/platform/agentHost/common/agentHostPlanReview.ts Adds a plan-review type guard.
src/vs/platform/agentHost/common/agentHostChatContributionsService.ts Exposes resumable error outcomes.
src/vs/platform/agentHost/common/agent.ts Adds optional provider resume API.

Review details

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

  • Files reviewed: 80/80 changed files
  • Comments generated: 4
  • Review effort level: Balanced

Comment thread src/vs/platform/agentHost/node/agentSideEffects.ts
Comment thread src/vs/workbench/contrib/chat/common/model/chatModel.ts
Defer queued turns while resumable failures remain terminal, exclude failed idle time from response duration, and document Try Again in Chat accessibility help. (Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add source-only recoverable failure helpers for launch testing and prevent concurrent confirmation actions while a retry is in flight. (Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

2 participants