You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Per-orchestration / per-thread budget ceiling for fan-outs #67
Follow-up from #34 (closed: the silent-kill half is fixed — budget-gated wake-ups now surface as a failed orchestrator with reason, Retry turn, and a desktop notification).
The only cap today is the global daily budget (SettingsModal.tsx:175, enforced by assertUnderDailyBudget in electron/services.js:1709 at run start: runner.js:3322, workflow.js:838). A single fan-out orchestration can burn the entire daily budget, starving everything else.
Idea: an optional per-thread (or per-orchestration) token/cost ceiling. When a fan-out's workers collectively cross it, the orchestrator's next wake-up is refused and the thread lands failed with the reason — reusing the visible surfacing path from #34 rather than dying silently.
Open questions:
Ceiling units: tokens, estimated cost, or worker count?
Where configured: per-orchestration at launch, or a global default in Settings?
Should hitting the ceiling pause (resumable) instead of failing?
Implemented on branch `coder/per-orchestration-per-thread-budget-ceil-fff8b9`.
Decisions on the open questions:
Units: USD cost — consistent with `dailyBudgetUsd` and already tracked per thread in `usageByThread.costUsd`; token counts are not comparable across providers/models.
Configured as a global default in Settings (`orchestrationBudgetUsd`). Per-launch config isn't actionable today because fan-outs are agent-driven (an orchestrator is just a normal thread that forks workers over the `coder-threads` MCP — there is no fan-out launch UI). A global per-orchestration cap directly fixes "one fan-out burns the whole daily budget".
Fails, reusing the Budget exhaustion kills orchestration silently #34 surfacing path — but the check lives only in `flushOrchNotices` (orchestration wake-ups), not in `startRun`, so the user can still send turns / hit Retry after raising the cap. Effectively resumable.
How it works:
`services.orchestrationSpend(store, threadId)` sums the orchestrator's own usage plus every direct `orchWorker` fork (nested crews are not rolled up — a worker that fans out is its own orchestrator with its own ceiling).
When a worker terminal queues a wake-up and the crew's collective spend has reached the ceiling, `assertUnderOrchestrationBudget` throws inside `flushOrchNotices`; the existing Budget exhaustion kills orchestration silently #34 catch lands the thread `failed` with `Not delivered: Orchestration budget reached ($X of $Y for this thread's crew`, arming the sidebar badge, Retry turn, and desktop notification. In-flight workers are never killed (same contract as the daily cap).
Files:electron/store.js (settings schema/normalize/validate), electron/services.js (spend sum + assert), electron/runner.js (wake-up gate), src/shared/ipc.ts + src/components/SettingsModal.tsx (Settings field next to the daily budget) + src/devCoder.ts/test/support/fakeCoder.ts mirrors, docs/ARCHITECTURE.md.
Tests: wake-up refusal lands failed-with-reason (electron/test/runner.test.js, mirroring the #34 case), crew under ceiling still wakes, user-sent turn still runs over the ceiling, settings validation/persistence (electron/test/budget-spend.test.js), SettingsModal field (test/settingsModal.test.tsx). Suites: renderer 703/703, core 38/38, memory 120/120, electron 763/772 (the 9 orch-server failures reproduce identically on pristine HEAD in this environment — port-bind issue, unrelated). Also fixed a stale deepEqual settings shape in budget-spend.test.js that was already red at HEAD (missing notifications key).
Possible follow-up if wanted: per-thread override of the global ceiling (thread field + IPC, same pattern as permissionMode).
EOF
)
Activity
currentbits commentedon Aug 16, 2026
Implemented on branch `coder/per-orchestration-per-thread-budget-ceil-fff8b9`.
Decisions on the open questions:
How it works:
Files:
electron/store.js(settings schema/normalize/validate),electron/services.js(spend sum + assert),electron/runner.js(wake-up gate),src/shared/ipc.ts+src/components/SettingsModal.tsx(Settings field next to the daily budget) +src/devCoder.ts/test/support/fakeCoder.tsmirrors,docs/ARCHITECTURE.md.Tests: wake-up refusal lands failed-with-reason (
electron/test/runner.test.js, mirroring the #34 case), crew under ceiling still wakes, user-sent turn still runs over the ceiling, settings validation/persistence (electron/test/budget-spend.test.js), SettingsModal field (test/settingsModal.test.tsx). Suites: renderer 703/703, core 38/38, memory 120/120, electron 763/772 (the 9 orch-server failures reproduce identically on pristine HEAD in this environment — port-bind issue, unrelated). Also fixed a staledeepEqualsettings shape inbudget-spend.test.jsthat was already red at HEAD (missingnotificationskey).Possible follow-up if wanted: per-thread override of the global ceiling (thread field + IPC, same pattern as
permissionMode).EOF
)
Merge pull request #123 from currentbits/coder/per-orchestration-per-…