Skip to content

Provide a way to snapshot threads outside the database #4714

Description

@ymichael

The workflow

Save a snapshot of a thread’s full history outside bb.db, in a searchable file format such as JSONL. Users could keep the snapshot for reference, grep it, or bring it back into an agent’s context later.

One use case is deleting old threads to reduce database size while keeping a copy of their transcripts. This applies to both manual cleanup and automatic retention.

What happens today

Feedback on #4476 reports a 2.1 GB database, with 910 MB of event data belonging to 813 archived threads. The user has held off deleting those threads because they want to preserve their transcripts.

The comment also identifies a limitation for plugins trying to export at deletion time: thread.deleted fires after soft deletion, and handlers are not awaited before permanent deletion. A plugin cannot reliably export the events before they disappear. This timing concern has not been independently reproduced for this issue.

What you would expect

A way to explicitly snapshot a thread’s full history to storage outside the database:

  • A documented, searchable file format such as JSONL.
  • A destination that can survive deletion of the original thread and its storage folder.
  • Access through the UI, CLI, and SDK.
  • Clear success or failure feedback so users know whether they have a saved copy.

Integration with manual deletion or automatic retention would be useful, but the snapshot capability and how cleanup uses it are open design questions. This request does not require every deletion to produce a snapshot or require snapshots to restore threads in BB.

Context and alternatives

Related: #3598 — undelete. This request focuses on keeping a portable copy of thread history outside the database; restoring deleted threads in BB is a separate concern.

Continuously mirroring every thread’s events is a possible workaround for the reported deletion-hook limitation, but requires exporting all history ahead of any deletion.

Searched open and closed issues for transcript export and thread snapshots; no matching request was found.

AGENT GENERATED

Activity

  1. added
    threads
    on Oct 2, 2026
  2. bb-slop-cop commented on Oct 2, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    Applied the missing classifications:

    • Type: Feature
    • Priority: Medium
    • Effort: High
    • Labels: threads

    This adds a portable history-saving capability rather than establishing an existing bug. Medium priority reflects a meaningful cleanup workflow with a workaround; High effort reflects unresolved storage/format decisions and UI, CLI, and SDK integration. No existing classifications were changed.

    No reproduction report or pull request: the final Type is Feature, so bug reproduction and automatic fixes are out of scope.

  3. patleeman commented on Oct 5, 2026

    @patleeman
    Contributor

    Thanks for writing this up, it captures it well. To answer what I'd want in a snapshot:

    Goal: back up my sessions as plain JSONL on disk so they survive thread deletion, and so agents can fall back to grepping older history when they need context. That second part is a big reason for this: old transcripts are useful context, and grep over flat files is something every agent already does well.

    Contents

    • One file per thread, one event per line, same shape as the events table (messages, tool calls and results, errors), so nothing is lost.
    • A first line with thread metadata: id, title, project, provider/model, parent/child thread ids, created/archived timestamps. This makes grep -l plus a quick head -1 enough to know what a file is.
    • A documented, versioned schema so agents and scripts can rely on it.

    Location

    • A configurable directory outside the data dir and thread storage, e.g. default ~/.bb/snapshots/<project>/<thread-id>.jsonl, so deleting the thread or its storage folder never touches it. Being able to point it at a synced folder (Dropbox, etc.) would be nice.
    • Plain JSONL by default so grep/rg work directly; compression as an option.

    When

    • Explicit: bb thread snapshot <id> and a bulk mode (e.g. all archived threads) so I can back up my ~800 archived threads once and then delete them.
    • Automatic: an option to snapshot on archive, and a guarantee that deletion or retention snapshots before the hard delete and stops if the snapshot fails. That ordering is the part a plugin can't do today.

    Restore isn't needed for me. A readable, greppable copy is enough. Nice-to-have: an index or a bb thread search --snapshots flag so agents can find old threads without knowing the path.

  4. brsbl commented on Oct 20, 2026

    @brsbl
    Collaborator

    Workaround in use until this ships: an hourly script automation reads bb.db read-only and writes <archive>/<YYYY-MM>/<thread>.jsonl.xz for each newly archived thread (line 1 is the thread row, the rest are its events in sequence order), plus an index.jsonl. A first-class bb thread export, or archive-to-cold-storage, would make this unnecessary and let archiving actually shrink the database.

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

    threads

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions