Skip to content

agentHost: resume failed turns without a new message - #329506

Draft
roblourens (roblourens) wants to merge 13 commits into
mainfrom
roblou/agents/resume-session-on-failure-with-button-d43abfdb
Draft

agentHost: resume failed turns without a new message#329506
roblourens (roblourens) wants to merge 13 commits into
mainfrom
roblou/agents/resume-session-on-failure-with-button-d43abfdb

Conversation

@roblourens

Copy link
Copy Markdown
Member

Summary

  • surface Try Again for Agent Host turns that fail with per-turn resume eligibility
  • reopen the same AHP turn and preserve its original message, partial response, usage, and start time
  • continue Copilot through sendMessages({ messages: [] }) and Codex through turn/start with an empty input
  • preserve multi-client optimistic reconciliation and map synthetic chat request IDs back to the durable AHP turn for file changes and truncation
  • coalesce Codex's physical empty-input retry turns into one logical AHP turn while retaining physical turn IDs for fork and rollback operations

Protocol dependency

Depends on microsoft/agent-host-protocol#371, which adds chat/turnResumed and per-turn resumable state for AHP 0.8.

Review notes

The highest-risk areas are:

  • concurrent retries from multiple connected clients
  • Copilot root-versus-subagent failure classification
  • Codex logical/physical turn mapping during replay, fork, and truncation
  • synthetic chat request IDs used by file changes and checkpoints

The implementation intentionally avoids a static agent capability: Turn.resumable is the precise gate, and provider resume is an optional host-side operation.

Validation

  • npm run typecheck-client
  • npm run valid-layers-check
  • npm run precommit
  • focused Agent Host unit matrix: 1,245 passing, 17 provider-gated
  • latest critical resume matrix: 791 passing before the final Codex replay fix
  • Codex replay mapper after latest-main merge: 15 passing
  • Codex Agent Host E2E: 38 passing, 49 provider-gated

(Written by Copilot)

roblourens (roblourens) and others added 7 commits July 25, 2026 16:16
Add capability-gated same-turn retries for Copilot and Codex without creating another user message. Reuse the existing Try Again error affordance, preserve partial output across retries and reloads, and reconcile concurrent client resumes safely.\n\n(Written by Copilot)\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
(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>
(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>
(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep standalone context compaction as its own /compact turn while continuing to coalesce true empty-input retry turns.

(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings August 6, 2026 23:27

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 AHP 0.8 failed-turn resumption while preserving logical turn state across clients and providers.

Changes:

  • Adds resumable turn protocol state, dispatch, reconciliation, and Try Again UI.
  • Implements zero-message resume for Copilot and Codex, including replay and turn-ID mapping.
  • Expands unit coverage for retries, concurrency, restoration, file changes, forks, and truncation.
Show a summary per file
File Description
src/vs/workbench/services/agentHost/browser/editorRemoteAgentHostServiceClient.ts Adds sequenced action dispatch.
src/vs/workbench/contrib/terminal/test/browser/agentHostPty.test.ts Updates connection mock.
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts Tests retry UI and reconciliation.
src/vs/workbench/contrib/chat/test/browser/agentHost/agentHostResponseFileChanges.test.ts Tests synthetic retry IDs.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/stateToProgressAdapter.ts Supports custom restored errors.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts Implements retry UI and observation.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostResponseFileChanges.ts Resolves retry IDs to turns.
src/vs/platform/agentHost/test/node/reducers.test.ts Tests resume reducer behavior.
src/vs/platform/agentHost/test/node/mockAgent.ts Adds mock resume support.
src/vs/platform/agentHost/test/node/mapSessionEvents.test.ts Tests restored Copilot failures.
src/vs/platform/agentHost/test/node/copilotTestEvents.ts Types session-error fixtures.
src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts Tests zero-message Copilot resume.
src/vs/platform/agentHost/test/node/copilotAgent.test.ts Tests Copilot resume routing.
src/vs/platform/agentHost/test/node/codex/codexReplayMapper.test.ts Tests retry-turn coalescing.
src/vs/platform/agentHost/test/node/codex/codexMapAppServerEvents.test.ts Tests resumable Codex errors.
src/vs/platform/agentHost/test/node/codex/codexForkPlan.test.ts Tests coalesced fork mapping.
src/vs/platform/agentHost/test/node/agentSideEffects.test.ts Tests resume side effects.
src/vs/platform/agentHost/test/node/agentService.test.ts Tests concurrent resume rejection.
src/vs/platform/agentHost/node/copilot/mapSessionEvents.ts Restores resumable Copilot errors.
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts Continues Copilot with no messages.
src/vs/platform/agentHost/node/copilot/copilotAgent.ts Routes Copilot resume operations.
src/vs/platform/agentHost/node/codex/codexReplayMapper.ts Coalesces physical retry turns.
src/vs/platform/agentHost/node/codex/codexMapAppServerEvents.ts Marks eligible Codex failures.
src/vs/platform/agentHost/node/codex/codexForkPlan.ts Maps logical to physical turns.
src/vs/platform/agentHost/node/codex/codexAgent.ts Implements empty-input Codex retry.
src/vs/platform/agentHost/node/agentSideEffects.ts Executes provider resume operations.
src/vs/platform/agentHost/node/agentService.ts Validates resume transitions.
src/vs/platform/agentHost/electron-browser/localAgentHostService.ts Exposes sequenced dispatch locally.
src/vs/platform/agentHost/common/state/sessionActions.ts Re-exports resume action.
src/vs/platform/agentHost/common/state/protocol/version/registry.ts Registers AHP 0.8 action.
src/vs/platform/agentHost/common/state/protocol/common/actions.ts Adds resume action type.
src/vs/platform/agentHost/common/state/protocol/channels-chat/state.ts Adds per-turn eligibility.
src/vs/platform/agentHost/common/state/protocol/channels-chat/reducer.ts Reopens failed turns.
src/vs/platform/agentHost/common/state/protocol/channels-chat/actions.ts Defines resume protocol data.
src/vs/platform/agentHost/common/state/protocol/action-origin.generated.ts Updates generated action metadata.
src/vs/platform/agentHost/common/state/protocol/.ahp-version Pins protocol dependency.
src/vs/platform/agentHost/common/agentService.ts Extends agent and connection APIs.
src/vs/platform/agentHost/browser/remoteAgentHostProtocolClient.ts Returns optimistic sequence IDs.
src/vs/platform/agentHost/browser/nullAgentHostService.ts Implements unsupported dispatch stub.

Review details

  • Files reviewed: 39/39 changed files
  • Comments generated: 3
  • Review effort level: Balanced

Comment thread src/vs/platform/agentHost/node/codex/codexAgent.ts Outdated
roblourens (roblourens) and others added 6 commits August 6, 2026 22:03
(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Prevent retries for archived and read-only chats, and preserve Codex model, customization, and trace context when resuming a turn.\n\n(Written by Copilot)\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Explain how keyboard and screen reader users can focus and activate Try Again for resumable failures.\n\n(Written by Copilot)\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Try Again affordance uses an existing standard Chat error button and does not need dedicated accessibility help text.\n\n(Written by Copilot)\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reserve the development-only recoverable error injection for the exact  prompt so ordinary error requests run normally.\n\n(Written by Copilot)\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Record and replay a full Copilot failure-to-resume flow, asserting one durable AHP turn and no duplicate user message. Remove Codex failed-turn resume support after black-box testing showed that an empty turn/start completes without invoking the model.\n\n(Written by Copilot)\n\nCo-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