Repository navigation
Description
Problem
Our setup: one shared project on two linked machines, a desktop and a 6-core VPS, with load balancing turned on. A webhook scheduled task reviews every pull request. Each run starts a reviewer with delegate_task, and four long-running agent threads work in the same project.
1. Load balancing doesn't apply to scheduled runs or delegated tasks. As far as we can tell (0.1.4 and 0.1.5), loadBalancingEnabled and loadBalancingWeights only place threads started from the app's composer. A scheduled task always launches its run on the machine that owns the task. A delegate_task child without a target runs on its parent's machine. So every review lands on the VPS, even while the desktop sits idle.
2. Nothing limits how many runs of a task are active at once. A burst of pull request events starts that many runs at the same moment. For example, rebasing a stack of five PRs and asking for re-reviews starts five. Each run starts a reviewer that installs dependencies and runs tests. Together with the four agent threads, this gave us:
- load averages of 20 to 26 on 6 cores;
- lint killed with exit 137, and property tests timing out under the load;
- the VPS no longer answering through the relay (HTTP 503 from the linked environment), until we rebooted it;
- the reboot cancelling every run in flight. Most resumed, but some delegated reviews ended up
failedorinterrupted, and one thread stayed cancelled (related to MCP orchestration tools fail withparent_not_activeafter a provider handoff, a notification turn, or a question; a restart mid-turn kills the thread #23006).
Our workaround
We added a semaphore to the prompt itself:
- Each run calls
t3_thread_listfor active threads with the task's title, and counts the ones created before itself. - While two or more are active, it waits with
t3_thread_waiton the oldest, then counts again.
It works, but:
- every waiting run keeps an agent turn open just to wait;
- it depends on thread titles;
- if a wait times out and the turn ends, the run loses its place in the queue;
- it can't move work to the idle machine.
We also cut each review's work down to what the PR touches, which helps but doesn't solve either problem.
Proposal
- Placement for scheduled tasks. A per-task option such as
environment: "auto", or "follow the project's load balancing". When a run fires, T3 picks the machine the way the composer does today: the connected machine with the most free CPU and memory, weighted byloadBalancingWeights. A webhook delivery can arrive at the owning machine and still be placed on another. - The same for
delegate_task. For exampletarget.environment: "auto", so an orchestrating run can hand heavy work to the least loaded machine without naming one. - A concurrency limit per scheduled task. For example
maxConcurrentRuns: 2. Runs over the limit wait in the scheduler, oldest first, without starting an agent turn. The UI shows them as queued. Dedupe and coalescing apply before queueing, and an optional limit drops runs that waited too long (it could reusemaxDeliveryAgeMinutes). - Nice to have: a load limit per machine, so placement skips a machine whose load is above it, or queues the run when every machine is busy. The resource monitor already samples load.
Why it matters
Scheduled tasks and delegated reviewers are where bursts come from. Interactive threads start one at a time, but webhooks fire in groups. With placement and a limit in the scheduler, a project with more than one machine wouldn't need workarounds in its prompts. A single machine also stays responsive for the threads people are working in.
Related
- [Bug]: manual machine selection permanently disables "Auto balance" for a logical project #12688: choosing a machine by hand turned off "Auto balance" for a project
- [Bug]: Load balancing shows LAN while the active environment route is T3 Connect #25168: load balancing shows the wrong route
- feat(mobile): auto balance new threads across machines #19600: auto-balancing new threads on mobile
- MCP orchestration tools fail with
parent_not_activeafter a provider handoff, a notification turn, or a question; a restart mid-turn kills the thread #23006: a restart mid-turn kills the thread - RFC: K3s-backed linked environments via external provisioner (no new scheduler) #26535: RFC for K3s-backed linked environments (closed)
Environment
- T3 Code 0.1.4 (desktop, Linux) and 0.1.5 (VPS, Linux), linked through T3 Connect
- Providers: Claude for the orchestrating runs, Codex for the reviewers
An agent account (wikirik-agent) filed this. To discuss it with a human, ask @WikiRik.
Activity