Skip to content

agentHost: restore missing Copilot worktrees on resume#320326

Draft
roblourens wants to merge 1 commit into
mainfrom
agents/vsckb-implement-what-happened-when-resuming-sess-fbae8a37
Draft

agentHost: restore missing Copilot worktrees on resume#320326
roblourens wants to merge 1 commit into
mainfrom
agents/vsckb-implement-what-happened-when-resuming-sess-fbae8a37

Conversation

@roblourens
Copy link
Copy Markdown
Member

Summary

  • recreate persisted Copilot worktrees before normal session resume when the directory was deleted
  • keep archived history lookup lazy by using the persisted repository root with an uncached temporary session
  • avoid replacing missing-directory resume failures with empty sessions
  • add regression coverage for archived lookup, live archive state, subagent lookup lifetime, and fallback classification

Validation

  • npm run compile-check-ts-native
  • node --experimental-strip-types build/hygiene.ts src/vs/platform/agentHost/node/copilot/copilotAgent.ts src/vs/platform/agentHost/node/copilot/copilotSessionLauncher.ts src/vs/platform/agentHost/test/node/copilotAgent.test.ts
  • npm run valid-layers-check
  • env -u ELECTRON_RUN_AS_NODE scripts/test.sh --run src/vs/platform/agentHost/test/node/copilotAgent.test.ts --grep "CopilotAgent"

(Written by Copilot)

Recreate persisted worktrees before normal Copilot session resume, but keep archived history lookup lazy by using the persisted repository root with an uncached temporary session. Avoid replacing missing-directory resume failures with empty sessions, and cover archived lookup races/subagent lifetime. (Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 7, 2026 21:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 Copilot session resume behavior in the Agent Host by handling cases where a persisted worktree directory has been deleted, and by making archived-history message lookup avoid expensive/eager worktree recreation and caching.

Changes:

  • Recreate missing persisted Copilot worktrees on resume (before invoking the SDK) to prevent resume failures when the worktree directory was deleted.
  • Treat missing-working-directory resume failures as non-recoverable (don’t replace the session with a fresh empty session).
  • Add regression tests covering: missing-directory resume fallback behavior, worktree recreation on resume, archived message lookup behavior (including subagent history lifetime).
Show a summary per file
File Description
src/vs/platform/agentHost/node/copilot/copilotAgent.ts Adds archived-aware message lookup and resume options to support worktree recreation and non-cached archived history reads.
src/vs/platform/agentHost/node/copilot/copilotSessionLauncher.ts Extends fallback classifier to avoid “empty session” fallback on missing-directory resume errors.
src/vs/platform/agentHost/test/node/copilotAgent.test.ts Adds targeted regression coverage for the new resume and archived-history behaviors.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Comment on lines +1275 to +1279
const isArchived = await this._isSessionArchived(session);
const hadActiveClient = this._activeClients.has(session);
let entry: CopilotAgentSession;
try {
entry = await this._resumeSession(sessionId, { recreateMissingWorktree: !isArchived, cache: !isArchived });
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