Skip to content

[Feature]: Retention/pruning for settled subagent thread projections (statev2.sqlite grows to 38.9 GB, 82% subagent turn_items) #43500

Not planned

Description

@Luzivog

Summary

Event log compaction (ProjectionMaintenanceV2.pruneEventStore) keeps orchestration_events bounded (~1.7 GB), and thread-content.purge cleans up rows once deleted_at IS NOT NULL, but settled/archived subagent and delegated-task threads are never deleted, so their V2 projection tables (orchestration_v2_projection_turn_items and orchestration_v2_projection_nodes) grow without bound.

On a heavily used Linux server running multi-agent orchestrations, this caused statev2.sqlite to reach 38.9 GB (36.2 GiB), turning every remote server update on ext4 into a 4.8 to 9.7 minute wait (278-489 s pre-update DB copy + 72-131 s index migrations on 2.64M turn_items rows).

Evidence (dbstat read-only measurement on 0.1.13-nightly.20261125.5245)

  • File size: 38.9 GB (36.2 GiB) (auto_vacuum = 2, freelist 2.1 GiB, internal page slack 5.4 GiB)
  • orchestration_v2_projection_turn_items + its indexes + turn_item_positions: ~23.5 GB (60%) across 2,641,297 rows
  • orchestration_v2_projection_nodes + its indexes: ~7.7 GB (20%) across 1,832,452 rows
  • orchestration_events + its indexes: ~1.9 GB (5%) (event compaction is working well)
  • Actual user_message + assistant_message payloads: 0.54 GB (1.4%)
  • Raw JSON payload breakdown in turn_items: dynamic_tool 5.83 GB (sampled Read tool calls average 38.8 KB each, separate from [Bug]: Claude Read images stay inline as base64 in both event and projection rows (1.4 GB, 46% of statev2.sqlite, in one week) #26591's base64 images) + command_execution 5.48 GB + reasoning 1.72 GB
  • Thread breakdown (14,805 non-deleted threads):
    • thread:delegated-task:*: 7,132 threads (6,068 settled) owning 1,324,276 turn items (50.1%)
    • thread:provider:* subagents: 6,741 threads (6,741 settled) owning 849,775 turn items (32.1%)
    • Human top-level threads: 904 threads owning 356,189 turn items (13.5%)

Together, subagent/delegated threads are 93.7% of active threads and 82.3% of all turn items, yet none are ever eligible for purgeableThreads because they are settled rather than deleted (and per #39199, even deleting a parent leaves subagents live).

Suggestions

  1. Optional retention / compaction policy for settled subagent projections: after a configurable retention window (e.g. 14-30 days after settlement, once parent has no active runs or pending context transfers), either purge settled subagent turn_items/nodes payloads (keeping the parent's subagent summary card intact) or prune bulky dynamic_tool (Read) / command_execution outputs while keeping assistant/user messages.
  2. Skip redundant pre-update DB backup when no migrations will run: when the staged target build's BUILD_MIGRATION_HEAD matches the database's recorded migration head (no pending schema migrations), the launcher could skip copying the entire database before starting the trial version, since no migration modifies the schema.

Activity

  1. juliusmarminge commented on Nov 26, 2026

    @juliusmarminge
    Member

    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.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions