Skip to content

Copilot CLI leaves behind orphaned session-state scaffold folders during aborted or incomplete session initialization/resume. #2836

Description

@JoakimHenriksson

Describe the bug

Copilot CLI leaves behind orphaned session-state scaffold folders during aborted or incomplete session initialization/resume.

These folders appear under ~/.copilot/session-state and contain minimal scaffold files like workspace.yaml, checkpoints/index.md, and empty checkpoints/, files/, and research/ directories, but they do not contain real session data like events.jsonl or session.db.

This causes the on-disk session corpus to diverge from what appears in copilot --resume.

Affected version

1.0.32

Steps to reproduce the behavior

  1. Use Copilot CLI on Windows.
  2. Start or attempt to resume sessions repeatedly, including cases where session startup/resume does not fully complete.
  3. Inspect ~/.copilot/session-state.
  4. Observe folders that contain workspace.yaml, checkpoints/index.md, and empty checkpoints/, files/, and research/ directories.
  5. Observe that these folders do not contain events.jsonl or session.db.
  6. Run copilot --resume and compare the visible sessions to the folders on disk.
  7. See that extra scaffold folders exist on disk but are not real resumable sessions.

Expected behavior

Session folders should only be created once initialization is durable and valid, or they should be cleaned up automatically if startup/resume aborts or fails.

Additional context

Environment:

  • Windows
  • GitHub Copilot CLI 1.0.32

Observed in local session corpus:

  • Multiple scaffold-only folders with summary_count: 0
  • Scaffold folders contain workspace.yaml and empty directories only
  • Real sessions contain events.jsonl and often session.db
  • A fresh scaffold folder was created during inspection of sessions via --resume
  • There was also one corrupted old session with events.jsonl but missing workspace metadata, which is a separate issue from the scaffold folders

Suggested fix:

  • Delay session directory creation until first durable write, or
  • create in a temp location and promote atomically, or
  • automatically clean up scaffold-only folders on failed initialization

Activity

added
area:sessionsSession management, resume, history, session picker, and session state
on Apr 19, 2026

JonasASchmidt-CM commented on Sep 8, 2026

@JonasASchmidt-CM

Still present in 1.0.84-1, on macOS — ~170 orphaned folders/month

Reproduced on macOS; the original report was Windows / 1.0.32. So this is cross-platform and still open.

Scale: 346 orphaned folders accumulated over 2 months against 2 sessions visible in the app — roughly 170/month. Each is ~3 KB, so this is not a disk-space emergency, but it is unbounded and it makes the on-disk corpus diverge badly from the app's session list.

Scaffold shape matches the original report, plus one file not mentioned there:

<uuid>/
├── workspace.yaml
├── checkpoints/index.md
├── .workspace-fork.lock   <-- not in the original report
├── files/                 (empty)
└── research/              (empty)

56 of 72 current orphans match this exactly. 1 had an events.jsonl.

New signal: client_name identifies the source. Every stub carries the same marker:

client_name: github/autopilot
user_named: false
summary_count: 0
fork_count: 0

55 of 56 were github/autopilot, 1 was github/cli. That points at the workspace-fork path rather than aborted resume alone, which may be why this has been hard to reproduce from the original steps.

Reproducible trigger: plugin installation. 19 stubs were created in a single 10-minute window matching plugin installs to the second:

Plugin installed at Stub created at
06:43:58 06:43:15, 06:43:34
06:44:03 06:44:03.309
06:44:06 - 06:44:08 06:44:22

Steps to reproduce:

  1. Install 3-4 plugins from the marketplace.
  2. Compare directory names in ~/.copilot/session-state/ against SELECT id FROM sessions in ~/.copilot/data.db.
  3. Observe scaffold folders with no corresponding session row.

Reliable detection rule: an orphan is any session-state directory with no matching row in data.db -> sessions. Safe additional guards before deleting: no events.jsonl, no session.db, no inuse.*.lock, and empty files/ and research/.

Suggested fix: remove the fork scaffold if the session is never committed to data.db, or sweep unreferenced scaffold dirs on startup.

Related: #3908 (extra empty dir on --resume), #4141 (unbounded session-state growth).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:sessionsSession management, resume, history, session picker, and session state

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions