Skip to content

bug: Claude Code resume starts a new raw.jsonl instead of continuing the active recording #541

@galexy

Description

@galexy

Symptom

When a Claude Code conversation is resumed (via `/resume` or via reopening the same session), `ox agent prime` fires again and creates a new recording session directory for the same agent_id, orphaning the prior in-flight recording in a "local only" state. The two halves of the conversation end up in two separate `raw.jsonl` files that are never stitched together, and the first half never gets finalized or uploaded.

Live repro (happened to this user today)

Agent_id `OxCh8K` was active from 2026-04-21T15:25:31Z (original Claude session start) through 2026-04-21T17:10Z. Conversation was paused and later resumed at 2026-04-22T00:00:49Z.

Two recording directories now exist under `repo_019c5812-...//.sageox/cache/sessions/`:

Dir raw.jsonl lines size First/last entry Status
`2026-04-21T15-25-galexy-OxCh8K/` 383 (header + 382 entries) 420 KB 15:25 → 17:10 (whole #525 bug-fix session including PR merge) `.recording.json` missing, marked "local only" by `ox session list`, no meta.json, no summary.*, never uploaded
`2026-04-22T00-00-galexy-OxCh8K/` 20 (header + 19 entries) 16 KB 00:00 → now (just the continuation turns) active recording

Both headers carry `agent_id: OxCh8K`. The agent_instances registry shows exactly one OxCh8K entry created 2026-04-21T08:30:34-07:00 — so the agent identity is stable across the resume. Only the recording file is not.

Expected

On resume, `ox agent prime` should either:

  1. Resume the existing recording — reopen the same `raw.jsonl` and `source_offset`, keep appending. Preserves one contiguous session on disk and on the ledger.
  2. Finalize the prior recording and start a new one — run the full stop → summarize → upload pipeline for the first half, then open a fresh recording for the continuation. Both halves reach the ledger, linked by parent/continuation metadata.

Either is fine. What must not happen is the current behavior: orphan the first half in "local only" with no meta.json and no summary, silently lose it.

Actual

  • `.recording.json` for the first session is gone (cleared by some hook between 17:10Z and 00:00Z — candidate culprits: `ClearRecordingStateForAgent` on SessionEnd / Clear hook, or daemon orphan/liveness reap).
  • No `meta.json`, `summary.json`, or `session.md` was written — the daemon's async finalize was never triggered.
  • `ox session list` shows the session as `✗ local only` — the content is on disk but the ledger never learned about it.
  • When the Claude session resumed, `ox agent prime` created `2026-04-22T00-00-galexy-OxCh8K/` from scratch instead of continuing the existing one.

What this user had to do to recover

Manual steps: `mkdir ledger/sessions/`, copy raw.jsonl + context-trace.jsonl + raw-session.md → session.md, `ox session regenerate --summary`, `ox session upload`. Works but is not something end users should need to discover.

Related

Acceptance criteria

  • After a Claude Code `/resume`, `ox session list` shows one session for the Claude conversation, not two — either resumed in place or finalized-then-continued.
  • If the prior half is finalized-and-continued, it MUST upload to the ledger (with its own `meta.json` + summary) rather than being left in "local only" state.
  • Integration test that simulates a resume (start a recording, stop Claude Code, re-prime with the same Claude session UUID) and asserts exactly one of the two expected outcomes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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