Skip to content

v0.8.8 tui: full UI freeze during multi-agent fan-out (likely SubAgentManager mutex contention) #510

@Hmbown

Description

@Hmbown

Summary

The TUI stops rendering and responding to input while a multi-agent workflow is active. Separate from #509 (cap counting) — that one is logic the model can work around. This one is fatal: the user can't see what's happening, can't cancel, can't type. Once the agent fan-out hits a few children, the UI freezes.

Repro

Multi-agent workflow: spawn 5 exploration agents → as each completes, spawn 5 implementation agents in parallel. Around the time the cap is being approached or contested, the TUI stops drawing and stops accepting input.

Suspect: shared mutex on the manager

crates/tui/src/tools/subagent/mod.rs:1195:

pub type SharedSubAgentManager = Arc<Mutex<SubAgentManager>>;

Every sub-agent operation (spawn, cancel, result, running_count, mailbox bookkeeping, status updates) takes the same global lock. The agent loop, the renderer, the mailbox pump, and N children all contend on it; the renderer starves.

The mailbox uses its own Arc<Mutex<...>> (mailbox.rs:265), compounding the contention.

Fix direction

  • Convert SharedSubAgentManager to Arc<RwLock<...>>. Most callers are read-mostly.
  • Audit manager.lock() call sites — many likely keep the guard alive across await points or tokio::spawn. Drop the guard before awaiting.
  • Move sub-agent state-change notifications to a dedicated channel so the renderer doesn't have to acquire the lock to observe progress.

Severity

High — makes the multi-agent workflow effectively unusable on real tasks.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingv0.8.8Targeting v0.8.8

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions