Skip to content

Commit 0bccd1d

Browse files
feat: experimental.primary_tools, allow user to set the tools that should only be available to primary agents (anomalyco#4913)
Co-authored-by: GitHub Action <action@github.com>
1 parent 91db82c commit 0bccd1d

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

packages/opencode/src/config/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,10 @@ export namespace Config {
668668
chatMaxRetries: z.number().optional().describe("Number of retries for chat completions on failure"),
669669
disable_paste_summary: z.boolean().optional(),
670670
batch_tool: z.boolean().optional().describe("Enable the batch tool"),
671+
primary_tools: z
672+
.array(z.string())
673+
.optional()
674+
.describe("Tools that should only be available to primary agents."),
671675
})
672676
.optional(),
673677
})

packages/opencode/src/tool/task.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Agent } from "../agent/agent"
99
import { SessionPrompt } from "../session/prompt"
1010
import { iife } from "@/util/iife"
1111
import { defer } from "@/util/defer"
12+
import { Config } from "../config/config"
1213

1314
export const TaskTool = Tool.define("task", async () => {
1415
const agents = await Agent.list().then((x) => x.filter((a) => a.mode !== "primary"))
@@ -77,6 +78,8 @@ export const TaskTool = Tool.define("task", async () => {
7778
ctx.abort.addEventListener("abort", cancel)
7879
using _ = defer(() => ctx.abort.removeEventListener("abort", cancel))
7980
const promptParts = await SessionPrompt.resolvePromptParts(params.prompt)
81+
82+
const config = await Config.get()
8083
const result = await SessionPrompt.prompt({
8184
messageID,
8285
sessionID: session.id,
@@ -89,6 +92,7 @@ export const TaskTool = Tool.define("task", async () => {
8992
todowrite: false,
9093
todoread: false,
9194
task: false,
95+
...Object.fromEntries((config.experimental?.primary_tools ?? []).map((t) => [t, false])),
9296
...agent.tools,
9397
},
9498
parts: promptParts,

packages/sdk/js/src/gen/types.gen.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,10 @@ export type Config = {
12491249
* Enable the batch tool
12501250
*/
12511251
batch_tool?: boolean
1252+
/**
1253+
* Tools that should only be available to primary agents.
1254+
*/
1255+
primary_tools?: Array<string>
12521256
}
12531257
}
12541258

0 commit comments

Comments
 (0)