Repository navigation
Description
CLI writes events that fail its own bundled session-events schema (ephemeral field missing)
Summary
Copilot CLI 1.0.54 writes session events to ~/.copilot/session-state/<sessionId>/events.jsonl without the ephemeral field, while the schema it ships with at pkg/universal/1.0.48/schemas/session-events.schema.json lists ephemeral as required on every event. The same file is later validated by the VS Code "Copilot CLI" integration on resume, which fails with:
Failed to open chat session: Session file is corrupted (line N: ephemeral: Invalid literal value, expected true)
The Zod error message is slightly misleading — it surfaces the last failing union branch ("expected true"); the underlying issue is that the field is absent entirely, not that it has the wrong value.
Environment
- Copilot CLI: 1.0.54
- OS: Windows 11 Pro 26100
- Node.js: v25.9.0 (also reproduces under v24.16.0)
- Schema in use:
~/.copilot/pkg/universal/1.0.48/schemas/session-events.schema.json
Reproduction
- Use the CLI for any non-trivial conversation (any session created on or before this version).
- Exit the CLI (
/exit). - In VS Code Stable, try to resume the session via the Copilot CLI integration.
- The "Failed to open chat session" error appears, referencing a line number where the CLI wrote events.
Affected event types
Snapshot from a single ~3-minute slice of one running CLI session — every event written by the CLI in that window was missing ephemeral:
| Count | Event type |
|---|---|
| 6 | assistant.message |
| 6 | assistant.turn_start |
| 6 | permission.completed |
| 6 | permission.requested |
| 6 | tool.execution_start |
| 5 | assistant.turn_end |
| 5 | hook.end |
| 5 | hook.start |
| 5 | tool.execution_complete |
| 1 | session.resume |
| 1 | system.message |
| 1 | user.message |
The bundled schema (session-events.schema.json) lists ephemeral as a required property with a discriminated boolean union (const: true for transient, false for persisted), but no events in the file carry the field.
Attempted workaround (does not fully resolve)
I tried backfilling "ephemeral": false onto every event in events.jsonl while the CLI was fully exited (lock file released, no process appending). Verified afterwards that every line in the file carried the field. VS Code still fails to resume with the same error, on the same line number.
That suggests one or more of:
- The validator is reading something other than
events.jsonl(e.g. a sibling metadata file or cached parse). - The discriminated union has additional constraints beyond just the
ephemeralfield's presence/value, and the actual failure is elsewhere on the record but the error pretty-printer attributes it toephemeral. - The "line N" in the error is not a line in the on-disk file but a line in some materialised view the validator emits.
For reference, the backfill script that was used:
$f = "$env:USERPROFILE\.copilot\session-state\<sessionId>\events.jsonl"
Copy-Item $f "$f.bak" -Force
$out = New-Object System.Collections.Generic.List[string]
foreach ($line in Get-Content $f) {
if (-not $line.Trim()) { continue }
$obj = $line | ConvertFrom-Json
if (-not ($obj.PSObject.Properties.Name -contains 'ephemeral')) {
$obj | Add-Member -NotePropertyName 'ephemeral' -NotePropertyValue $false
}
$out.Add( ($obj | ConvertTo-Json -Compress -Depth 100) )
}
[System.IO.File]::WriteAllLines($f, $out)So this report is really two findings:
- The CLI writer is emitting events that fail its own bundled schema (
ephemeralalways absent). - Even after manually fixing that on disk, VS Code resume still errors with the same message — suggesting the error message is at minimum misleading and possibly pointing to a different underlying problem.
Expected behaviour
Either:
- The writer always emits
ephemeralon every event it appends (preferred — keeps the schema strict), or - The schema makes
ephemeraloptional with a default offalsefor persisted events.
Option 1 is the safer fix: schema strictness has caught a real bug here.
Impact
- VS Code cannot resume any CLI session created or updated by 1.0.54, and (per the section above) a manual backfill of the missing field does not restore resumability either.
- Users who alternate between CLI and VS Code lose access to their session history through the GUI path.
- The CLI itself is unaffected — it tolerates the missing field on its own reads — so the failure surfaces only via the VS Code integration.
Additional notes
~/.copilot/vscode.session.metadata.cache.jsoncontinues to list the session as resumable, so the failure happens at file-parse time, not discovery time.- No data is lost — the events are well-formed JSON apart from the missing field — and a manual rewrite is recoverable.
Activity
milesbuckton commentedon May 28, 2026
Follow-up: second VS Code resume failure mode on CLI 1.0.55-7
Hitting a related-but-distinct failure on a newer CLI build when opening a CLI-created session in VS Code:
Environment
Repro
/exit.Notes
ephemeral: Invalid literal value, expected truemessage, so this looks like a different validation/parsing path in the VS Code loader rather than the same schema mismatch.ephemeralbackfill workaround from the original report does not clear this one either.events.jsonlline accounting) is being computed as negative — possibly an off-by-one when the loader encounters a record shape it doesn't recognise and falls back to a default of-1.Happy to attach a redacted
events.jsonl/ session-state directory if useful for repro.patniko commentedon Oct 26, 2026
Thanks for the report. We've shipped fixes in this area since this was filed (most recently in Copilot CLI v1.0.85), and we believe this may now be resolved. Could you retest on the latest release (Copilot CLI v1.0.103) and let us know whether you still see it? If we don't hear back in a couple of weeks, we may close this issue — you can always reopen it.
Triaged as part of a Copilot SDK backlog review, with help from GitHub Copilot.