Skip to content

feat(platform): dispatch one agent across hundreds of workers - #4998

Merged
yannickmonney merged 9 commits into
mainfrom
feat/dispatch-fleet-scale
Oct 15, 2026
Merged

yannickmonney merged 9 commits into
mainfrom
feat/dispatch-fleet-scale

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

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)

  • Runs at once and runs per agent now share one maximum, DISPATCH_RUNS_MAX (500), exported from the dispatch schema. It equals the sandbox quota's ceiling, now named SANDBOX_SESSION_BUDGET_MAX. The editor's duplicate constants are deleted.
  • A write refuses runs per agent above runs at once (field perAgentConcurrency).
  • The stored and observed shape (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.
  • Defaults are unchanged, including perAgentConcurrency 1, so existing documents hash the same.

Pass (TASK-R63)

  • A pass reads up to 500 ready tasks (was 200), so one pass can fill the largest pool.
  • With no spacing, a pass starts work for at most 2 minutes (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.
  • With a spacing, a pass still makes one start. The docs give the ramp: the 256th run starts 255 spacings after the first, which is 2 h 7 min 30 s at the default 30 s.
  • 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 as waiting between starts instead of "no ready work". The loop that starts a plan's picks is startPicks, which takes the clock, the host, the start and the gate note as effects, so its wiring is unit-tested (dispatch-pass.test.ts). runDispatchPass takes budgetMs so the integration lane can run a pass out of time after its first start.

Model capacity (TASK-R40, TASK-R43)

  • When a hold clears, the parked runs wake in waves 15 s apart, oldest first: 1, 2, 4… runs, at most a sixteenth of the waiters per wave. Previously they woke one run every 15 s.
  • Up to 16 waiters still wake one at a time. 256 waiters, or even 500, have all started within 4 min 45 s instead of about 64 min.
  • New dispatch work ramps onto a model that answers again the same way. The clear records when the model answered (migration 0215, 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 as model_ramp and 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)

  • Each pool agent now carries runCounts: total, running, queued, and waiting by reason, from one grouped query.
  • It lists at most its 50 oldest runs (DISPATCH_RUNS_LISTED).
  • Above five runs, the Dispatch page shows those counts and five runs. An aria-expanded button shows the rest of the listed runs, and the page says how many more runs are not listed.
  • GET /api/v1/projects/{id}/dispatch answers the same shape.

Contract, docs and tests

  • API contract 3.46.0: OpenAPI, both fingerprints, the skill snapshot and the settings-kind description are updated.
  • Docs in EN/DE/FR: dispatch.md gains a limits table, the ramp math and the wave wake-up. project-agents.md, admin/sandboxes.md, task-automation.md and api-reference.md are updated.
  • New message keys in en/de/fr; de-CH needs no override.
  • New manual box PROJ-B24, with matching rows in the automation reference.
  • New real-Postgres lane checkDispatchRampAndBudget covers the ramp after a clear and a pass with a zero budget. checkModelCapacityRetry reads the ramp a settle starts.
  • For the next release's authored notes (this PR writes none: notes are prepared by the release before its candidate, .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; runCounts and the 50-run runs list in GET /api/v1/projects/{id}/dispatch; the model-capacity ramp; upgrade the Tale CLI with the platform before declaring project-dispatch.

Out of scope: cross-project dispatch and Incus admission.

Checklist

  • bun run check passes. 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).
  • Translations: services/platform/messages/{en,de,fr}/projects.yml. No de-CH override is needed (no ß).
  • Docs updated in docs/{en,de,fr}/.
  • README: N/A, no README states these limits.

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):

  • Unit, platform server: 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.
  • Unit, platform UI: app/features/projects: 32 files, 315 tests pass.
  • Unit, docs: @tale/docs 716 tests pass.
  • Earlier round, unchanged since: @tale/shared (1013 tests), @tale/cli src/lib/config (300 tests), app/features/settings/sandboxes.
  • Typecheck: platform (12 GiB heap) is clean at each of the four new commits.
  • Lint: type-aware oxlint over the whole platform workspace is clean at each commit.
  • Repo gates: oxfmt --check on 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.
  • SQL: the new migration and queries ran against a scratch PGlite outside the clone: the recovery upsert and cleanup, the ramp count (provider 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 real tale-db image.

Not run:

  • backend:integration was not run: it needs a throwaway Postgres the repo's script does not start. Its lanes checkFleetDispatch, checkDispatchRampAndBudget (new) and checkModelCapacityRetry (new ramp assertion) are only typechecked here; the Backend integration check runs them.
  • No real browser and no live stack were used; PROJ-B24 is the manual half.
  • A pass request that finds another request of the same project already waiting is dropped (short queue policy). So the pass after a budget stop 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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant