From 096d2487edceeb9c98c4f7921135da3b4dafb547 Mon Sep 17 00:00:00 2001 From: spoons-and-mirrors <212802214+spoons-and-mirrors@users.noreply.github.com> Date: Thu, 15 Jan 2026 22:39:42 +0100 Subject: [PATCH 1/5] fix(tool): batch tool outputs duplication and restrictive arbitrary values - fix: stagger batch firing - tweak: max 25 tools --- packages/opencode/src/tool/batch.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/opencode/src/tool/batch.ts b/packages/opencode/src/tool/batch.ts index 8bffbd54a28..7c5ab200686 100644 --- a/packages/opencode/src/tool/batch.ts +++ b/packages/opencode/src/tool/batch.ts @@ -33,8 +33,8 @@ export const BatchTool = Tool.define("batch", async () => { const { Session } = await import("../session") const { Identifier } = await import("../id/id") - const toolCalls = params.tool_calls.slice(0, 10) - const discardedCalls = params.tool_calls.slice(10) + const toolCalls = params.tool_calls.slice(0, 25) + const discardedCalls = params.tool_calls.slice(25) const { ToolRegistry } = await import("./registry") const availableTools = await ToolRegistry.tools({ modelID: "", providerID: "" }) @@ -123,7 +123,15 @@ export const BatchTool = Tool.define("batch", async () => { } } - const results = await Promise.all(toolCalls.map((call) => executeCall(call))) + const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)) + const results: typeof toolCalls extends (infer T)[] + ? (Awaited> & { tool: string })[] + : never = [] + + for (let i = 0; i < toolCalls.length; i++) { + if (i > 0) await delay(50) + results.push(await executeCall(toolCalls[i])) + } // Add discarded calls as errors const now = Date.now() @@ -139,14 +147,14 @@ export const BatchTool = Tool.define("batch", async () => { state: { status: "error", input: call.parameters, - error: "Maximum of 10 tools allowed in batch", + error: "Maximum of 25 tools allowed in batch", time: { start: now, end: now }, }, }) results.push({ success: false as const, tool: call.tool, - error: new Error("Maximum of 10 tools allowed in batch"), + error: new Error("Maximum of 25 tools allowed in batch"), }) } From a06cd3d04e4d68dc04202fb4ec16de7f54679c14 Mon Sep 17 00:00:00 2001 From: spoons-and-mirrors <212802214+spoons-and-mirrors@users.noreply.github.com> Date: Mon, 19 Jan 2026 00:02:22 +0100 Subject: [PATCH 2/5] using Bun.sleep --- packages/opencode/src/tool/batch.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/opencode/src/tool/batch.ts b/packages/opencode/src/tool/batch.ts index 7c5ab200686..d3ed4165ae0 100644 --- a/packages/opencode/src/tool/batch.ts +++ b/packages/opencode/src/tool/batch.ts @@ -123,13 +123,12 @@ export const BatchTool = Tool.define("batch", async () => { } } - const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)) const results: typeof toolCalls extends (infer T)[] ? (Awaited> & { tool: string })[] : never = [] for (let i = 0; i < toolCalls.length; i++) { - if (i > 0) await delay(50) + if (i > 0) await Bun.sleep(50) results.push(await executeCall(toolCalls[i])) } From a6fc71240524d80309c11d19cf5e6bee5a737614 Mon Sep 17 00:00:00 2001 From: spoons-and-mirrors <212802214+spoons-and-mirrors@users.noreply.github.com> Date: Mon, 19 Jan 2026 15:52:20 +0100 Subject: [PATCH 3/5] reverting staggered tool execution --- packages/opencode/src/tool/batch.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/opencode/src/tool/batch.ts b/packages/opencode/src/tool/batch.ts index d3ed4165ae0..ba34eb48f5c 100644 --- a/packages/opencode/src/tool/batch.ts +++ b/packages/opencode/src/tool/batch.ts @@ -123,14 +123,7 @@ export const BatchTool = Tool.define("batch", async () => { } } - const results: typeof toolCalls extends (infer T)[] - ? (Awaited> & { tool: string })[] - : never = [] - - for (let i = 0; i < toolCalls.length; i++) { - if (i > 0) await Bun.sleep(50) - results.push(await executeCall(toolCalls[i])) - } + const results = await Promise.all(toolCalls.map((call) => executeCall(call))) // Add discarded calls as errors const now = Date.now() From 6941cb4b6a4f5e16a3bc322cb48b83fb6ce2341c Mon Sep 17 00:00:00 2001 From: spoons-and-mirrors <212802214+spoons-and-mirrors@users.noreply.github.com> Date: Mon, 19 Jan 2026 16:08:37 +0100 Subject: [PATCH 4/5] description --- packages/opencode/src/tool/batch.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/opencode/src/tool/batch.txt b/packages/opencode/src/tool/batch.txt index b1b6a6010f5..968a6c3f07c 100644 --- a/packages/opencode/src/tool/batch.txt +++ b/packages/opencode/src/tool/batch.txt @@ -6,7 +6,7 @@ Payload Format (JSON array): [{"tool": "read", "parameters": {"filePath": "src/index.ts", "limit": 350}},{"tool": "grep", "parameters": {"pattern": "Session\\.updatePart", "include": "src/**/*.ts"}},{"tool": "bash", "parameters": {"command": "git status", "description": "Shows working tree status"}}] Notes: -- 1–10 tool calls per batch +- 1–25 tool calls per batch - All calls start in parallel; ordering NOT guaranteed - Partial failures do not stop other tool calls - Do NOT use the batch tool within another batch tool. From 425cef4bb8db80c8f8e0cc675224f85aa069ec4a Mon Sep 17 00:00:00 2001 From: spoons-and-mirrors <212802214+spoons-and-mirrors@users.noreply.github.com> Date: Mon, 19 Jan 2026 16:09:17 +0100 Subject: [PATCH 5/5] add some padding on tool description --- packages/opencode/src/tool/batch.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/opencode/src/tool/batch.txt b/packages/opencode/src/tool/batch.txt index 968a6c3f07c..565eb4dd433 100644 --- a/packages/opencode/src/tool/batch.txt +++ b/packages/opencode/src/tool/batch.txt @@ -6,7 +6,7 @@ Payload Format (JSON array): [{"tool": "read", "parameters": {"filePath": "src/index.ts", "limit": 350}},{"tool": "grep", "parameters": {"pattern": "Session\\.updatePart", "include": "src/**/*.ts"}},{"tool": "bash", "parameters": {"command": "git status", "description": "Shows working tree status"}}] Notes: -- 1–25 tool calls per batch +- 1–20 tool calls per batch - All calls start in parallel; ordering NOT guaranteed - Partial failures do not stop other tool calls - Do NOT use the batch tool within another batch tool.