Skip to content

Thousands of untracked files in a worktree make its threads laggy (1.5 MB status payload) #5331

Closed

Description

@iamhenry

Summary

If a thread's worktree contains thousands of untracked files, that thread becomes very laggy in the BB UI. Threads in other environments stay responsive.

In our case, agents running a long QA loop saved screenshots and build output inside the worktree. Git ended up seeing about 7,000 untracked files. The environment status response grew to 1.5 MB, almost all of it a list of every changed file. BB fetches that status again whenever the worktree changes, and the agents kept writing files. The result was repeated server and host-daemon event loop stalls, plus a UI that was hard to use.

Versions and environment

  • bb 0.46.1-nightly, macOS 15.6 on an 8-core Apple Silicon virtual machine
  • Provider: OpenCode v2 plugin. This is probably provider-independent, since the status comes from the environment, not the provider.
  • Git worktree environment. About 7,000 untracked files (roughly 2.4 GB of PNG, JSON, and TXT, plus built .app bundles). Only 19 real tracked changes.

Steps to reproduce

  1. Create a thread in any git repo with a worktree environment.
  2. In that worktree, create a few thousand untracked files that are not gitignored:
    mkdir -p qa-evidence
    for i in $(seq 1 7000); do echo "run $i" > "qa-evidence/shot-$i.txt"; done
  3. Check the size of the status response:
    bb environment status <environment-id> --json | wc -c
  4. Keep the worktree changing, the way an agent does while it saves evidence:
    while true; do date > "qa-evidence/live-$RANDOM.txt"; sleep 1; done
  5. Open the thread in the BB UI and use it: scroll, type, switch panels. Then do the same in a thread from another environment.
  6. Watch the server and host-daemon logs for Event loop stalled lines.

Not yet run as written; this was put together from the real incident. In the incident, the files were PNG screenshots of about 0.1 to 3 MB each. Small text files should be enough to show the large payload. Large files may also be needed to trigger the watcher warnings.

Expected vs actual

expected: a thread in a worktree with thousands of untracked files stays about as responsive as any other thread. The status response stays small, for example counts plus a capped or paginated file list.
actual:   the status response lists every file (1.5 MB for about 7,000 files, compared with a few KB for a normal worktree). The thread's UI lags badly, and the server and host daemon log repeated event loop stalls.

Evidence

  • bb environment status <env> --json: 1,465,322 bytes, with workspace.workingTree.files holding 6,953 entries (6,934 untracked). Two other environments on the same machine returned 588 bytes and 5 KB.
  • Host daemon log: 101 Host daemon event loop stalled warnings in about 8 hours, the worst 3.5 s. Also Watcher subscription requires targeted recovery with Events were dropped by the FSEvents client. File system must be re-scanned.
  • Server log: Event loop stalled entries whose in-flight work includes GET /api/v1/environments/<env>/status for this environment.
  • The affected thread was small: about 1,200 events and 14 turns. So its own timeline was not the cause.

What you ruled out

  • Thread size and timeline cost. The thread was small, and other threads were fine.
  • Model or provider latency.
  • Machine load alone. Other threads on the same machine at the same time felt normal.
  • Workaround: gitignore the generated folders, or write them outside the worktree. That fixes it for one project. BB still has no guard against agents that write a lot of generated files.

Activity

  1. added theissue type on Oct 10, 2026
  2. added
    workspaces
    partial-repro
    on Oct 10, 2026
  3. bb-slop-cop commented on Oct 10, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Medium · Effort: Medium. Applied labels: workspaces, perf, partial-repro.
    • Report: Reproduction and root cause.
    • Verdict: PARTIALLY REPRODUCED · Confidence: high for the payload mechanism. Two clean trusted-main checkouts returned 1,365,527 bytes / 7,019 entries with 7,000 untracked artifacts and 19 tracked edits. UI lag, event-loop stalls, and macOS watcher recovery remain unverified.
    • Root cause: Workspace.getStatus expands and returns every untracked path; existing budgets limit line-stat reads, not the file list. The authored payload probe fails identically in both checkouts; all 35 existing workspace tests pass.
    • No PR: safely bounding status needs explicit totals/truncation semantics across the shared protocol and consumers, outside the simple-fix gate.

    AGENT GENERATED

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

    partial-reproperfworkspaces

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions