Skip to content
Source
Sign inSign up
pingdotgg/t3code

Retention for settled and archived threads: archiving frees nothing, and a 3-week-old database already stalls the server #42372

Closedgileck(GitHub profile, opens in a new tab) opened this issue 1 comment

Before submitting

  • I searched existing issues. #40677 asked for database retention and was closed with that part not done ("open a new issue if what is left still matters"). #17845 covers delete keeping every row. This issue asks for the missing feature: a supported way to drop old thread history.

Area

apps/server

Setup

  • T3 Code v0.1.10, desktop app, macOS (Apple Silicon)
  • One machine, about 3 weeks of use, 5 projects
  • Threads are started by a script with t3 thread start ... --worktree ... (Codex and Cursor providers). Usually 3–6 run at once, never dozens.

What happens

  1. statev2.sqlite grows all the time: 564 MB, then 595 MB about 2 hours later, with 3–5 threads running.

  2. t3 doctor --dry-run says: Database: 562.5 MiB, 0 KiB reclaimable. So all of it is live data.

  3. Where the space is (read-only dbstat):

    TableMB
    orchestration_v2_projection_turn_items230
    orchestration_events129
    orchestration_v2_projection_nodes62
    orchestration_v2_projection_messages + message search~35
  4. 535 threads in total. In one project, 189 threads are settled. They hold about 96 MB of turn-item payload, and nobody will open them again.

  5. With this database the server hung. event-loop-stalls.ndjson shows stalls of 26 s and 37 s, and SQLite transactions on statev2.sqlite took 6–9 s. The main process sat at ~100% CPU, and every CLI call failed with:

    ServerAuthSessionTokenIssueError: Failed to issue session token.
      at cli.thread.withThreadTools ...
      [cause]: Error: database is locked

    No new trace lines were written for ~50 minutes. SIGTERM did nothing, and only SIGKILL plus the launcher's restart fixed it.

  6. I archived 9 settled threads in the app to free space. All their rows stayed. For example, one thread still has 68 turn items and another has 45:

    SELECT t.title, count(i.turn_item_id)
    FROM orchestration_v2_projection_threads t
    LEFT JOIN orchestration_v2_projection_turn_items i USING (thread_id)
    WHERE t.archived_at IS NOT NULL
    GROUP BY t.thread_id;

    Archive only sets archived_at. Together with #17845 (delete only sets deleted_at), this leaves a user with no way to make the database smaller.

Expected behavior

A supported way to drop the stored history of threads that are done, for example:

  • a setting: "delete the history of archived (or settled) threads after N days", or
  • a command: t3 doctor --prune-archived --older-than 30d (or similar),

that deletes their events, turn items, nodes and messages, keeps a small tombstone, and then frees the space with an incremental vacuum.

Why it matters

The database grows with every turn, and per #37877 the server's cost per event grows with database size. So a machine that runs a few agents every day slowly gets slower until it stalls, even with few threads running. Today the only fix a user has is to delete statev2.sqlite and lose everything.

#40677, #17845, #21154, #37877, #38792, #41997

  1. tanstack-source added labelsfeature

  2. Thanks for writing this up. It asks for new behaviour rather than reporting a defect, so it does not belong in the bug tracker and I'm closing it as not planned here. Feature ideas are discussed in Discussions: please post it there.

  3. juliusmarminge closed this

Sign in to join this conversation.