Skip to content

Long-lived session shows as corrupted on resume despite valid events.jsonl #2209

@KarnikJain

Description

@KarnikJain

Describe the bug

A session with heavy usage (204 premium requests, 34 user messages, 3 segments across resumes) shows as corrupted when attempting to resume. Investigation shows the events.jsonl file is structurally valid:

  • All 8,366 lines parse as valid JSON (no SyntaxError)
  • File ends cleanly with a newline
  • Proper session.startsession.shutdown structure
  • session.db passes SQLite PRAGMA integrity_check
  • workspace.yaml is well-formed

The only anomaly is file size: 18 MB / 8,366 event lines accumulated over 3 session segments (1 start + 2 resumes).

Affected version

  • Created with: GitHub Copilot CLI 1.0.9
  • Resume attempted with: GitHub Copilot CLI 1.0.10
  • Model: Claude Opus 4.6 (1M context)

Session diagnostics

Metric Value
Session ID be25adf7-5860-40ac-bfb6-2eb178a0f848
events.jsonl size 18,427,560 bytes (8,366 lines)
Session segments 3 (start → shutdown → resume → shutdown → resume → shutdown)
User messages 34
Assistant turns 589
Tool executions 2,103
Premium requests 204 total (24 + 6 + 174 across segments)
Sub-agents spawned 38

Session segment boundaries

Line     1: session.start     ts=2026-03-20T06:02:49
Line  2103: session.shutdown  shutdownType=routine  premiumRequests=24
Line  2104: session.resume    ts=2026-03-20T16:15:42
Line  2393: session.shutdown  shutdownType=routine  premiumRequests=6
Line  2394: session.resume    ts=2026-03-21T04:00:38
Line  8366: session.shutdown  shutdownType=routine  premiumRequests=174

Workaround applied

Trimmed events.jsonl to only the last segment (lines 2394–8366) with a synthetic session.start replacing the session.resume. Reduced from 18 MB → 14 MB.

Expected behavior

  1. Sessions with valid events.jsonl should not show as corrupted regardless of file size
  2. If there is a size/event-count limit, the CLI should proactively compact or checkpoint the events file (e.g., via /compact) before it becomes unresumable
  3. Better error messaging — "corrupted" is misleading when the file is structurally valid; a message like "Session too large to resume (18 MB). Try /compact" would help

Possible root causes

  • No size/event limit handling: The resume logic may OOM or timeout parsing 18 MB of events
  • Version mismatch (1.0.9 → 1.0.10): Schema changes between versions may reject older event formats
  • Missing auto-compaction: Long sessions with many sub-agents and tool calls accumulate events without any pruning

Related issues

Additional context

Environment: Linux DevBox (WSL-like), long-running FunOS firmware development session with extensive tool usage (builds, grep, file edits, sub-agents).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions