Repository navigation
feat(platform): dispatch one agent across hundreds of workers - #4998
Merged
Merged
Conversation
Runs at once and runs per agent were capped at 100 and 5, far below what an organization's agent workers allow. Both now share one maximum, DISPATCH_RUNS_MAX, equal to the sandbox quota's ceiling (SANDBOX_SESSION_BUDGET_MAX, 500), and the editor reads it from the schema instead of keeping its own copy. A write refuses runs per agent above runs at once. A dispatch stored before that rule still reads (storedProjectDispatchSchema, and the managed-configuration observation the CLI and the editor read), so the pass keeps starting its work and the next save or apply corrects it. A pass now reads up to 500 ready tasks and starts work for at most two minutes, its first pick always tried, inside its five-minute lease; the next pass goes on at once. With a spacing, a pass still makes one start. Contract 3.46.0 (the dispatch bounds).
A cleared model-capacity hold woke its parked runs one every 15 seconds, so 256 waiters took over an hour to start. They now start in waves 15 seconds apart, oldest park first: one run, then twice as many each wave, up to a sixteenth of them at once (modelCapacityWakeDelaysMs). The model that just answered meets a few runs first; if it refuses them, its hold is back before the larger waves come. Up to sixteen waiters still wake one at a time; 256 or even 500 have all started within 4 min 45 s.
The dispatch readback listed every live run of each pool agent, and the
Dispatch page rendered each as a list item: one agent on 256 runs made
an answer and a table row of 256 entries. Each agent now carries
runCounts (total, running, queued, and waiting by reason, read in one
grouped query) and its 50 oldest runs at most (DISPATCH_RUNS_LISTED).
The page counts an agent's runs by what they do once it holds more than
five, lists five, and offers the rest of the listed runs behind an
aria-expanded button, saying how many more are not listed.
GET /api/v1/projects/{id}/dispatch answers the same shape; contract
3.46.0 records it. The fleet dispatch integration check holds the counts
to the list against real Postgres, and PROJ-B24 is the manual half.
A pass that used its two minutes recorded the stop of its last start (started or held), so the readback called an idle agent of the pool "no ready work" while its work waited for the pass that follows at once, and nothing exercised the budget check inside the pass: only the pure passOutOfTime predicate was tested. The loop that starts a plan's picks is now startPicks, which takes the clock, the host, the start and the gate note as effects, the way the pass already took a stand-in host. A pass out of time stops as budget (Recent passes: "It ran out of time; the next pass goes on at once"), and the readback reads it, like a spacing, as waiting between starts. runDispatchPass takes a budgetMs option so a test can run a pass out of time after its first start. dispatch-pass.test.ts drives startPicks with a stand-in clock: the time is checked before the host is asked, the first pick is always tried, the next pass is asked for at the time the pass stopped, and a held host or a spacing still stop the pass as before.
Clearing a model's capacity hold deleted the hold and asked every switched-on dispatch for a pass at once. The waves only paced the runs that had parked on the model: the next pass read the model as free and, with no time between starts, started its whole free room on it, up to 500 runs of one agent meeting a model that had just answered. The clear now also records when the model answered again (app.model_capacity_recoveries, migration 0215: a table of its own, as an older image would read a kept hold row as a hold that ran out). For the five minutes the waves of 500 runs take, a pass starts no more new runs on that model than those waves have let through (1, 3, 7, 15, 31, 63, then 32 more every 15 seconds), counting every run of the organization started on it since the clear, whoever started it. The agents on one model share the ramp; work for an agent on another model goes on. A pass the ramp held back stops as model_ramp and asks for the next pass at the next wave; the readback reads it as waiting between starts. A spacing slower than the ramp still applies. Tests: the ramp's waves and its end (model-capacity-holds.test.ts), the plan holding work for a ramp and filling a pool of 256 in 13 waves within three minutes (dispatch-plan.test.ts), and the pass asking again at the next wave unless the host, the spacing or its time stopped it first (dispatch-pass.test.ts). TASK-R40, TASK-R43 and TASK-R46 say it; the dispatch and task automation docs in en, de and fr too.
checkDispatchRampAndBudget keeps Coder alone in a pool with no time between starts. Once its model's hold clears, the first pass starts the one run the ramp lets through and asks again at the next wave, a pass before that wave starts nothing, the next wave starts the two held back, and a ramp that is over holds nothing. A pass run with a zero budget starts one pick, stops as budget with its next pass at the time it stopped, asks for that pass with no delay of its own (the lane keeps each request's delay and adds a day), and the next pass starts the rest. checkModelCapacityRetry now also reads the ramp a settle starts, and both lanes drop their recovery rows. The quota raise both dispatch lanes need is one helper. The automation reference names the new lane and dispatch-pass.test.ts.
The notes still named contract 3.45.0 and migrations up to 0214. They now name 3.46.0 and 0215, the 500-run limits of a dispatch and the refusal of runs per agent above runs at once, runCounts and the 50-run list of the dispatch read, the waves new dispatch work meets a model that answers again, and that the Tale CLI is upgraded with the platform before a project-dispatch is declared: an older CLI does not know the resource, and a build from before the 500-run limits cannot plan a dispatch above 5 runs per agent or 100 at once.
This was referenced Oct 15, 2026
yannickmonney
marked this pull request as ready for review
October 15, 2026 13:29
yannickmonney
added a commit
that referenced
this pull request
Oct 15, 2026
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The fleet's own Tale will keep one coding agent on up to 256 parallel runs, one worker and sandbox each, through native project dispatch (#4987). Dispatch capped that at 100 runs at once and 5 per agent. Waking 256 runs parked on model capacity took over an hour, a cleared hold let dispatch start its whole free room on the model at once, and the readback listed every live run in one row.
Bounds (
TASK-R62)DISPATCH_RUNS_MAX(500), exported from the dispatch schema. It equals the sandbox quota's ceiling, now namedSANDBOX_SESSION_BUDGET_MAX. The editor's duplicate constants are deleted.perAgentConcurrency).storedProjectDispatchSchema,managedProjectDispatchObservationSchema) still reads a dispatch saved before that rule. The pass keeps starting its work, the editor opens it, and the CLI plans its correction instead of failing to read it.perAgentConcurrency1, so existing documents hash the same.Pass (
TASK-R63)PASS_BUDGET_MS), always trying its first pick, then asks for the next pass at once. This stays well inside its 5-minute lease (PASS_LEASE_MS). The per-start host admission is unchanged.budget(Recent passes: "It ran out of time; the next pass goes on at once"), and the readback reads it as waiting between starts instead of "no ready work". The loop that starts a plan's picks isstartPicks, which takes the clock, the host, the start and the gate note as effects, so its wiring is unit-tested (dispatch-pass.test.ts).runDispatchPasstakesbudgetMsso the integration lane can run a pass out of time after its first start.Model capacity (
TASK-R40,TASK-R43)app.model_capacity_recoveries). It is a table of its own, not a column on the hold: an older image would read a kept hold row as a hold that ran out and make its next claim a probe. For 5 minutes a pass starts no more new runs on that model than the waves of 500 have let through (1, 3, 7, 15, 31, 63, then 32 more every 15 s). It counts every run of the organization started on the model since the clear, whoever started it. The agents on one model share the ramp; agents on other models go on. A pass the ramp held stops asmodel_rampand asks for the next pass at the next wave. A pool of 256 refills within 3 minutes, and a spacing slower than the ramp still applies.Readback (
TASK-R46)runCounts: total, running, queued, and waiting by reason, from one grouped query.DISPATCH_RUNS_LISTED).aria-expandedbutton shows the rest of the listed runs, and the page says how many more runs are not listed.GET /api/v1/projects/{id}/dispatchanswers the same shape.Contract, docs and tests
dispatch.mdgains a limits table, the ramp math and the wave wake-up.project-agents.md,admin/sandboxes.md,task-automation.mdandapi-reference.mdare updated.PROJ-B24, with matching rows in the automation reference.checkDispatchRampAndBudgetcovers the ramp after a clear and a pass with a zero budget.checkModelCapacityRetryreads the ramp a settle starts..github/release-notes/README.md; v0.5.92's candidate does not contain this change): contract 3.46.0 and migration 0215; the 500-run limits and the refusal of runs per agent above runs at once;runCountsand the 50-runrunslist inGET /api/v1/projects/{id}/dispatch; the model-capacity ramp; upgrade the Tale CLI with the platform before declaringproject-dispatch.Out of scope: cross-project dispatch and Incus admission.
Checklist
bun run checkpasses. Not run as a whole (shared, loaded Mac); the targeted gates are listed under Test plan, and CI runs the rest.bun run lint:sast: not run as a whole. The pre-commit Opengrep step ran on the staged files (skip-if-uncached mode).services/platform/messages/{en,de,fr}/projects.yml. No de-CH override is needed (no ß).docs/{en,de,fr}/.Test plan
These ran locally on the final tree (base 92f9a86, head 681f8b8; the last commit only rewords one sentence of
spec.md, after which the spec guards ran again):backend/domains/tasks,backend/db,backend/jobs,backend/domains/sandbox,backend/domains/organizations,tests/guards,lib/i18n,lib/mcp,scripts/openapi,app/lib/backend: 234 files, 3913 tests pass.app/features/projects: 32 files, 315 tests pass.@tale/docs716 tests pass.@tale/shared(1013 tests),@tale/clisrc/lib/config(300 tests),app/features/settings/sandboxes.oxfmt --checkon the changed files,knip --workspace services/platform(three findings, all in files this PR does not touch),lint:manual,lint:links, and the pre-commit conflict-marker, oxfmt and Opengrep steps all pass.NULL/''alike, other providers, organizations and earlier runs excluded), the facts query, and the lane's delay arithmetic. The scratch is deleted. This is not the realtale-dbimage.Not run:
backend:integrationwas not run: it needs a throwaway Postgres the repo's script does not start. Its lanescheckFleetDispatch,checkDispatchRampAndBudget(new) andcheckModelCapacityRetry(new ramp assertion) are only typechecked here; the Backend integration check runs them.PROJ-B24is the manual half.shortqueue policy). So the pass after abudgetstop can wait for that request's own time (15 s after a lease clash, or a host recheck) rather than run "at once". This predates this PR and is not changed here.