Skip to content

Session resume fails on corrupted session file (SDK less tolerant than CLI) #210

Description

@ChrisRomp

Summary

The bridge fails to resume a session when the session file contains a corrupted JSON line. The CLI handles the same file gracefully (presumably skipping or repairing the bad line), but the SDK's session.resume treats it as fatal.

Steps to Reproduce

  1. Have a long-running session that accumulates a large session file (~20k+ lines)
  2. Session file gets corrupted (likely from a truncated write -- e.g., bridge restart mid-write)
  3. Bridge restarts and attempts to resume the session
  4. /resume <session-id> also fails with the same error

Expected Behavior

Session resumes successfully (as the CLI does), either by:

  • Skipping/repairing the corrupted line
  • Truncating the session history to the last valid checkpoint
  • Gracefully degrading with a warning rather than refusing to load

Actual Behavior

Resume fails with:

Request session.resume failed with message: Session file is corrupted
(line 20712: SyntaxError: Unterminated string in JSON at position 8287 (line 1 column 8288))

The bridge auto-resume path handles this by creating a new session (expected fallback), but /resume surfaces the error to the user with no recovery option.

Component

session-manager / SDK (@github/copilot-sdk)

Version

0689632

Platform

macOS (Darwin), Node.js v25.6.1, SDK 0.3.0, CLI 1.0.36

Additional Context

  • Session ID: 4357b1a4-56c5-4340-b3dd-4f236b3647a4
  • The CLI (copilot binary) can load the same session file successfully
  • Root cause is likely the SDK doing strict JSON parsing line-by-line vs the CLI having error recovery
  • This may be an upstream SDK issue rather than something fixable in bridge code
  • Potential bridge-side mitigation: detect corruption on /resume and offer to truncate the session file to the last valid line

Reported By

Agent (automated)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions