Skip to content

[Bug]: storageCleanup never removes isolated sub-agent worktrees (pullRequests empty on child thread) #41682

Done

Description

@Luzivog

Area

apps/server

Summary

Unlike #16472 (which covered a worktree shared between a parent thread and its subagents), isolated sub-agent worktrees created via delegate_task with isolation: "worktree" are never cleaned up by storageCleanup (worktreeOnMerge: true, worktreeOnDelete: true, worktreeAfterDays: 30), causing unbounded disk growth.

Live evidence (0.1.12-nightly.20261122.5111)

  • On a 24/7 host, ~/.t3/worktrees/ accumulated 79 GB across 239 live T3 worktrees (168 under one monorepo = 70.6 GB, 34 under another = 7.7 GB).
  • Mapping each live worktree to orchestration_v2_projection_threads: 211 of 239 belong to sub-agent threads (lineage.relationshipToParent = "subagent") whose own pullRequests array is empty (PRs are linked on the parent thread or merged directly without linking on the child), and sub-agent threads are never deleted, so neither worktreeOnMerge nor worktreeOnDelete ever fires.

Expected behavior

storageCleanup should also clean up clean, completed/settled sub-agent worktrees when their branch is merged/deleted on origin, when the parent thread's linked PR merges, or on a shorter configurable sub-agent retention window.

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