A desktop coding agent with free access to frontier models.
TypeScript
feat(swarm): no cap on how many sub-agents run or start per turn
Samrat Talukdarbaa2601cc093
diff --git a/apps/server/src/omnirush-runtime-config.test.ts b/apps/server/src/omnirush-runtime-config.test.tsindex ad21d6fa..6c52ed9a 100644--- a/apps/server/src/omnirush-runtime-config.test.ts+++ b/apps/server/src/omnirush-runtime-config.test.ts@@ -350,7 +350,9 @@ describe("omnirush runtime config file", () => {expect(prompt).toContain("## Sub-agent swarms");expect(prompt).toContain("Never start a swarm for a small or quick request.");expect(prompt).toContain("`swarm.md` at the workspace root");- expect(prompt).toContain(`at most ${OMNIRUSH_SWARM_MAX_RUNNING} run at once and ${OMNIRUSH_SWARM_MAX_PER_TURN} start per turn`);+ expect(prompt).toContain("There is no limit on how many run at once or start per turn");+ expect(OMNIRUSH_SWARM_MAX_RUNNING).toBe(Number.POSITIVE_INFINITY);+ expect(OMNIRUSH_SWARM_MAX_PER_TURN).toBe(Number.POSITIVE_INFINITY);expect(prompt.indexOf("## Sub-agent swarms")).toBeLessThan(prompt.indexOf("## Editing files"));});diff --git a/apps/server/src/omnirush-swarm.ts b/apps/server/src/omnirush-swarm.tsindex 1b7c8c54..d16682f0 100644--- a/apps/server/src/omnirush-swarm.ts+++ b/apps/server/src/omnirush-swarm.ts@@ -21,11 +21,13 @@*/export const OMNIRUSH_SUBAGENT_DEPTH = 3;-/** Sub-agents of one main session (all layers) running at the same time. */-export const OMNIRUSH_SWARM_MAX_RUNNING = 8;--/** Sub-agents one main-session turn may start in all (all layers, resumes included). */-export const OMNIRUSH_SWARM_MAX_PER_TURN = 24;+/**+ * Sub-agents of one main session running at once, and started per turn: no+ * cap by owner decision (2026-09-24: "one should spawn as many as+ * required"); only the depth stays bounded.+ */+export const OMNIRUSH_SWARM_MAX_RUNNING = Number.POSITIVE_INFINITY;+export const OMNIRUSH_SWARM_MAX_PER_TURN = Number.POSITIVE_INFINITY;/** The coordination board, relative to the workspace root. */export const OMNIRUSH_SWARM_FILE = "swarm.md";@@ -42,7 +44,7 @@ Most requests need no sub-agents, or one or two task calls. Run a swarm only wheA swarm is coordinated through \`${OMNIRUSH_SWARM_FILE}\` at the workspace root:1. Before delegating, create or update \`${OMNIRUSH_SWARM_FILE}\` with: \`# Goal\` (one paragraph), \`## Tasks\` (a table: id, task, owner, status, result; ids like T1, T2, and T1.1 for a sub-task of T1; status is todo, running, done or blocked), \`## Findings\` (shared facts, one bullet each, with the task id), \`## Decisions\` (choices every agent must follow).2. Give each sub-agent one task id. Its task-tool prompt names the id, the task, and says: read \`${OMNIRUSH_SWARM_FILE}\` first; set your row to running; when done, set it to done with a one-line result and append your findings under your id; edit only your own rows and sections; report back briefly.-3. Sub-agents may split their own task: they add sub-task rows (T1.1, T1.2) and give the same instructions to their own sub-agents. Sub-agents nest at most ${OMNIRUSH_SUBAGENT_DEPTH} layers deep; at most ${OMNIRUSH_SWARM_MAX_RUNNING} run at once and ${OMNIRUSH_SWARM_MAX_PER_TURN} start per turn. If the task tool refuses because of a limit, finish the work yourself instead of retrying.+3. Sub-agents may split their own task: they add sub-task rows (T1.1, T1.2) and give the same instructions to their own sub-agents. Sub-agents nest at most ${OMNIRUSH_SUBAGENT_DEPTH} layers deep. There is no limit on how many run at once or start per turn: start as many as the work needs, and no more.4. Launch independent tasks in parallel (several task calls in one message); give tasks that edit the same files to one agent.5. When every task is done, read \`${OMNIRUSH_SWARM_FILE}\`, check and merge the results, record the outcome under \`## Decisions\` or a final \`## Summary\`, and answer the user. Keep \`${OMNIRUSH_SWARM_FILE}\` in the workspace unless the user asks you to remove it.`;diff --git a/apps/server/src/opencode-plugins/omnirush-swarm.test.ts b/apps/server/src/opencode-plugins/omnirush-swarm.test.tsindex 5f0682f7..c040413b 100644--- a/apps/server/src/opencode-plugins/omnirush-swarm.test.ts+++ b/apps/server/src/opencode-plugins/omnirush-swarm.test.ts@@ -41,46 +41,17 @@ const partDone = (hooks: Hooks, callID: string, status = "completed") =>hooks.event({ event: { type: "message.part.updated", properties: { part: { type: "tool", tool: "task", callID, state: { status } } } } });describe("omnirush swarm plugin", () => {- test("limits the sub-agents of one main-session tree running at once, across every layer", async () => {+ test("puts no cap on how many sub-agents run at once or start per turn", async () => {const { hooks } = await setup();await created(hooks, "ses_main");await created(hooks, "ses_child", "ses_main");await created(hooks, "ses_grand", "ses_child");- for (let i = 0; i < OMNIRUSH_SWARM_MAX_RUNNING; i += 1) {+ // Far past the old caps (8 running, 24 per turn), none refused.+ for (let i = 0; i < 200; i += 1) {await task(hooks, i % 3 === 0 ? "ses_main" : i % 3 === 1 ? "ses_child" : "ses_grand", `call_${i}`);}- await expect(task(hooks, "ses_grand", "call_over")).rejects.toThrow(/already running/);- // Another main session has its own budget.- await created(hooks, "ses_other");- await task(hooks, "ses_other", "other_1");- // One finished (event) and one failed call free two slots.- await partDone(hooks, "call_0");- await partDone(hooks, "call_1", "error");- await task(hooks, "ses_child", "call_again_1");- await task(hooks, "ses_main", "call_again_2");- await expect(task(hooks, "ses_main", "call_again_3")).rejects.toThrow(/already running/);- // tool.execute.after frees a slot too; the main session going idle frees all.- await hooks["tool.execute.after"]({ tool: "task", callID: "call_2" });- await task(hooks, "ses_main", "call_again_3");- await hooks.event({ event: { type: "session.status", properties: { sessionID: "ses_main", status: { type: "idle" } } } });- await task(hooks, "ses_grand", "after_idle");- });-- test("limits sub-agents started per main-session turn; a new prompt to the main session refills it", async () => {- const { hooks } = await setup();- await created(hooks, "ses_main");- await created(hooks, "ses_child", "ses_main");- for (let i = 0; i < OMNIRUSH_SWARM_MAX_PER_TURN; i += 1) {- const callID = `call_${i}`;- await task(hooks, i % 2 ? "ses_child" : "ses_main", callID);- await partDone(hooks, callID);- }- await expect(task(hooks, "ses_child", "call_over")).rejects.toThrow(`started ${OMNIRUSH_SWARM_MAX_PER_TURN} sub-agents`);- // A sub-agent's own prompt is not a new turn.- await hooks["chat.message"]({ sessionID: "ses_child" });- await expect(task(hooks, "ses_main", "call_over")).rejects.toThrow(/Do not retry/);- await hooks["chat.message"]({ sessionID: "ses_main" });- await task(hooks, "ses_child", "next_turn");+ expect(OMNIRUSH_SWARM_MAX_RUNNING).toBe(Number.POSITIVE_INFINITY);+ expect(OMNIRUSH_SWARM_MAX_PER_TURN).toBe(Number.POSITIVE_INFINITY);});test("other tools and unknown sessions pass; parents are read from the engine once", async () => {