Fix Multi-Agent Run Hanging and Finalization Issues · Entire

This is stuck for way too long

There's just no indicator what the final agent is still doing. Also, Status says "done" but footer says 3 succeeded and 1 failed?

AGENT STATUS DURATION TOKENS PREVIEW

4 agent(s) done — 3 succeeded, 1 failed, 0 cancelled

Finalizing output...


Root cause — found and reproduced

It's not a deadlock; it's a super-linear blowup in glamour markdown rendering during the post-run finalize phase.

Finalization process:

Rendering latency:

input render time
500 KB 1.1 s
2 MB 6 s
4 MB 49 s
8 MB 4m30s
16 MB didn't finish (>5 min)

Investigation Summary:

  1. The finalize sink chain for a TTY multi-agent run caused delays in the rendering of multi-MB narratives, leading to hanging.
  2. When an agent has a large output, the rendering delays are exacerbated.

Fixes Implemented:

The bug

When a review run finishes, the CLI prints each agent's output as nicely formatted markdown via a library called glamour. That formatting step is really slow on large inputs.

The solution

  1. Cap the formatting size: If the text is bigger than 256 KB, skip the fancy formatting and just print it plain.
  2. Make the wait visible: The footer shows a spinning indicator and a climbing timer during the finalization.

Findings Persistence Fix

When a review run is cancelled during synthesis, findings were lost because the context was reused. To fix this:

Test Implemented

Added tests to ensure that findings persist despite being previously cancelled.

Process Group Kill on Cancel

Fixed cancellation to properly kill all processes spawned by agents to prevent the hanging issue when terminating the run. Now the system can cleanly cancel all related processes.

Overall Branch Summary