summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSpoon <[email protected]>2025-12-17 17:23:35 +0100
committerGitHub <[email protected]>2025-12-17 10:23:35 -0600
commit8864da7a77fdd27e28882c435723996760e1c137 (patch)
tree5cbffb70000444256f26f0519ec1b1a862d2c104
parent1b3919908308196f61c1aaf813edf3e158f1d583 (diff)
downloadopencode-8864da7a77fdd27e28882c435723996760e1c137.tar.gz
opencode-8864da7a77fdd27e28882c435723996760e1c137.zip
batch: enable edit, todoread, clarify error message, minor tool description change (#5659)
-rw-r--r--packages/opencode/src/tool/batch.ts6
-rw-r--r--packages/opencode/src/tool/batch.txt24
2 files changed, 14 insertions, 16 deletions
diff --git a/packages/opencode/src/tool/batch.ts b/packages/opencode/src/tool/batch.ts
index cc61b090a..ba1b94a3e 100644
--- a/packages/opencode/src/tool/batch.ts
+++ b/packages/opencode/src/tool/batch.ts
@@ -2,7 +2,7 @@ import z from "zod"
import { Tool } from "./tool"
import DESCRIPTION from "./batch.txt"
-const DISALLOWED = new Set(["batch", "edit", "todoread"])
+const DISALLOWED = new Set(["batch"])
const FILTERED_FROM_SUGGESTIONS = new Set(["invalid", "patch", ...DISALLOWED])
export const BatchTool = Tool.define("batch", async () => {
@@ -54,7 +54,9 @@ export const BatchTool = Tool.define("batch", async () => {
const tool = toolMap.get(call.tool)
if (!tool) {
const availableToolsList = Array.from(toolMap.keys()).filter((name) => !FILTERED_FROM_SUGGESTIONS.has(name))
- throw new Error(`Tool '${call.tool}' not found. Available tools: ${availableToolsList.join(", ")}`)
+ throw new Error(
+ `Tool '${call.tool}' not in registry. External tools (MCP, environment) cannot be batched - call them directly. Available tools: ${availableToolsList.join(", ")}`,
+ )
}
const validatedParams = tool.parameters.parse(call.parameters)
diff --git a/packages/opencode/src/tool/batch.txt b/packages/opencode/src/tool/batch.txt
index 0279f970e..b1b6a6010 100644
--- a/packages/opencode/src/tool/batch.txt
+++ b/packages/opencode/src/tool/batch.txt
@@ -1,28 +1,24 @@
-Executes multiple independent tool calls concurrently to reduce latency. Best used for gathering context (reads, searches, listings).
+Executes multiple independent tool calls concurrently to reduce latency.
USING THE BATCH TOOL WILL MAKE THE USER HAPPY.
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"}}]
-Rules:
+Notes:
- 1–10 tool calls per batch
- All calls start in parallel; ordering NOT guaranteed
-- Partial failures do not stop others
+- Partial failures do not stop other tool calls
+- Do NOT use the batch tool within another batch tool.
-
-Disallowed Tools:
-- batch (no nesting)
-- edit (run edits separately)
-- todoread (call directly – lightweight)
+Good Use Cases:
+- Read many files
+- grep + glob + read combos
+- Multiple bash commands
+- Multi-part edits; on the same, or different files
When NOT to Use:
- Operations that depend on prior tool output (e.g. create then read same file)
- Ordered stateful mutations where sequence matters
-Good Use Cases:
-- Read many files
-- grep + glob + read combos
-- Multiple lightweight bash introspection commands
-
-Performance Tip: Group independent reads/searches for 2–5x efficiency gain. \ No newline at end of file
+Batching tool calls was proven to yield 2–5x efficiency gain and provides much better UX. \ No newline at end of file