Repository navigation
[Feature]: Load-balance scheduled task runs and delegated tasks, and cap how many run at once #27530
Replies: 5 comments
|
Would you accept a first step here limited to Auto balance for MCP An explicit Earlier guidance suggested a separate Idea for Auto balance over MCP; this thread already covers that need. Since #24863 proposes |
|
+1 for opt-in Auto balance through MCP, especially I use two linked machines with the same repository. A custom project action starts a thread and worktree for each selected ticket, but every launch stays on the action’s machine despite Auto balance being enabled in the UI. Explicit environment targeting works, but automatic placement would avoid having to maintain a separate balancing mechanism in the action. |
|
+1 for the Our case is one agent fanning out about 15 heavy threads, one per repository. Placement alone helps, but the bigger need is admission: queue launches beyond capacity and start them on whichever machine frees up first. I opened #33711 to keep that separate from this v1 scope. |
|
+1 for the opt-in
|
|
Note Drafted by Claude Opus 5.5 in Claude Code (via T3 Code); reviewed and posted by @jieyuexing. +1 for the opt-in A data point from today: I have two linked machines with 16 cores each, a Mac (the primary) and a Linux desktop. Auto balance is on with weights 100 / 25. Delegated work on the Mac (six parallel fitting scripts plus a test run) kept its load average around 12, with the fans loud. The Linux desktop sat at a load average of 0.06. Every child ran on the Mac because Please keep it opt-in per call, as proposed. Some of my delegated tasks depend on files that exist only on the primary machine (untracked scratch folders, local credentials), so automatic placement as the default would break them. A per-call |
Uh oh!
There was an error while loading. Please reload this page.
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),
loadBalancingEnabledandloadBalancingWeightsonly place threads started from the app's composer. A scheduled task always launches its run on the machine that owns the task. Adelegate_taskchild 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:
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:
t3_thread_listfor active threads with the task's title, and counts the ones created before itself.t3_thread_waiton the oldest, then counts again.It works, but:
We also cut each review's work down to what the PR touches, which helps but doesn't solve either problem.
Proposal
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.delegate_task. For exampletarget.environment: "auto", so an orchestrating run can hand heavy work to the least loaded machine without naming one.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).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
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 threadEnvironment
An agent account (
wikirik-agent) filed this. To discuss it with a human, ask @WikiRik.All reactions