Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions packages/opencode/src/agent/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export namespace Agent {
.optional(),
prompt: z.string().optional(),
tools: z.record(z.string(), z.boolean()),
subagents: z.record(z.string(), z.boolean()),
options: z.record(z.string(), z.any()),
maxSteps: z.number().int().positive().optional(),
})
Expand Down Expand Up @@ -110,7 +109,6 @@ export namespace Agent {
todowrite: false,
...defaultTools,
},
subagents: {},
options: {},
permission: agentPermission,
mode: "subagent",
Expand All @@ -125,7 +123,6 @@ export namespace Agent {
write: false,
...defaultTools,
},
subagents: {},
description: `Fast agent specialized for exploring codebases. Use this when you need to quickly find files by patterns (eg. "src/components/**/*.tsx"), search code for keywords (eg. "API endpoints"), or answer questions about the codebase (eg. "how do API endpoints work?"). When calling this agent, specify the desired thoroughness level: "quick" for basic searches, "medium" for moderate exploration, or "very thorough" for comprehensive analysis across multiple locations and naming conventions. (Tools: All tools)`,
prompt: [
`You are a file search specialist. You excel at thoroughly navigating and exploring codebases.`,
Expand Down Expand Up @@ -155,7 +152,6 @@ export namespace Agent {
build: {
name: "build",
tools: { ...defaultTools },
subagents: {},
options: {},
permission: agentPermission,
mode: "primary",
Expand All @@ -168,7 +164,6 @@ export namespace Agent {
tools: {
...defaultTools,
},
subagents: {},
mode: "primary",
builtIn: true,
},
Expand All @@ -186,15 +181,14 @@ export namespace Agent {
permission: agentPermission,
options: {},
tools: {},
subagents: {},
builtIn: false,
}
const {
name,
model,
prompt,
tools,
subagents,
subagents: _subagents,
description,
temperature,
top_p,
Expand All @@ -219,11 +213,6 @@ export namespace Agent {
...defaultTools,
...item.tools,
}
if (subagents)
item.subagents = {
...item.subagents,
...subagents,
}
if (description) item.description = description
if (temperature != undefined) item.temperature = temperature
if (top_p != undefined) item.topP = top_p
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { SplitBorder } from "@tui/component/border"
import { useCommandDialog } from "@tui/component/dialog-command"
import { useTerminalDimensions } from "@opentui/solid"
import { Locale } from "@/util/locale"
import { Wildcard } from "@/util/wildcard"
import type { PromptInfo } from "./history"

export type AutocompleteRef = {
Expand Down Expand Up @@ -185,11 +184,8 @@ export function Autocomplete(props: {
)

const agents = createMemo(() => {
const current = local.agent.current() as { subagents?: Record<string, boolean> }
const subagents = current.subagents ?? {}
return sync.data.agent
.filter((agent) => !agent.builtIn && agent.mode !== "primary")
.filter((agent) => Wildcard.all(agent.name, subagents) !== false)
.map(
(agent): AutocompleteOption => ({
display: "@" + agent.name,
Expand Down
1 change: 0 additions & 1 deletion packages/opencode/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,6 @@ export namespace Config {
top_p: z.number().optional(),
prompt: z.string().optional(),
tools: z.record(z.string(), z.boolean()).optional(),
subagents: z.record(z.string(), z.boolean()).optional(),
disable: z.boolean().optional(),
description: z.string().optional().describe("Description of when to use the agent"),
mode: z.enum(["subagent", "primary", "all"]).optional(),
Expand Down
18 changes: 1 addition & 17 deletions packages/opencode/src/session/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { Config } from "../config/config"
import { NamedError } from "@opencode-ai/util/error"
import { fn } from "@/util/fn"
import { SessionProcessor } from "./processor"
import { TaskTool, filterSubagents, TASK_DESCRIPTION } from "@/tool/task"
import { TaskTool, TASK_DESCRIPTION } from "@/tool/task"
import { SessionStatus } from "./status"
import { Token } from "@/util/token"

Expand Down Expand Up @@ -857,22 +857,6 @@ export namespace SessionPrompt {
tools[key] = item
}

// Regenerate task tool description with filtered subagents
if (tools.task) {
const all = await Agent.list().then((x) => x.filter((a) => a.mode !== "primary"))
const filtered = filterSubagents(all, input.agent.subagents)
const description = TASK_DESCRIPTION.replace(
"{agents}",
filtered
.map((a) => `- ${a.name}: ${a.description ?? "This subagent should only be called manually by the user."}`)
.join("\n"),
)
tools.task = {
...tools.task,
description,
}
}

return tools
}

Expand Down
8 changes: 0 additions & 8 deletions packages/opencode/src/tool/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,10 @@ import { Agent } from "../agent/agent"
import { SessionPrompt } from "../session/prompt"
import { iife } from "@/util/iife"
import { defer } from "@/util/defer"
import { Wildcard } from "@/util/wildcard"
import { Config } from "../config/config"

export { DESCRIPTION as TASK_DESCRIPTION }

export function filterSubagents(agents: Agent.Info[], subagents: Record<string, boolean>) {
return agents.filter((a) => Wildcard.all(a.name, subagents) !== false)
}

export const TaskTool = Tool.define("task", async () => {
const agents = await Agent.list().then((x) => x.filter((a) => a.mode !== "primary"))
const description = DESCRIPTION.replace(
Expand All @@ -37,9 +32,6 @@ export const TaskTool = Tool.define("task", async () => {
async execute(params, ctx) {
const agent = await Agent.get(params.subagent_type)
if (!agent) throw new Error(`Unknown agent type: ${params.subagent_type} is not a valid agent type`)
const calling = await Agent.get(ctx.agent)
if (calling && Wildcard.all(params.subagent_type, calling.subagents) === false)
throw new Error(`Agent '${params.subagent_type}' is not available to ${ctx.agent}`)
const session = await iife(async () => {
if (params.session_id) {
const found = await Session.get(params.session_id).catch(() => {})
Expand Down
93 changes: 0 additions & 93 deletions packages/opencode/test/subagents-filter.test.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/sdk/js/src/v2/gen/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -983,9 +983,6 @@ export type AgentConfig = {
tools?: {
[key: string]: boolean
}
subagents?: {
[key: string]: boolean
}
disable?: boolean
/**
* Description of when to use the agent
Expand Down Expand Up @@ -1017,9 +1014,6 @@ export type AgentConfig = {
| unknown
| string
| number
| {
[key: string]: boolean
}
| {
[key: string]: boolean
}
Expand Down Expand Up @@ -1631,9 +1625,6 @@ export type Agent = {
tools: {
[key: string]: boolean
}
subagents: {
[key: string]: boolean
}
options: {
[key: string]: unknown
}
Expand Down
20 changes: 1 addition & 19 deletions packages/sdk/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -7229,15 +7229,6 @@
"type": "boolean"
}
},
"subagents": {
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"type": "boolean"
}
},
"disable": {
"type": "boolean"
},
Expand Down Expand Up @@ -8791,15 +8782,6 @@
"type": "boolean"
}
},
"subagents": {
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"type": "boolean"
}
},
"options": {
"type": "object",
"propertyNames": {
Expand All @@ -8813,7 +8795,7 @@
"maximum": 9007199254740991
}
},
"required": ["name", "mode", "builtIn", "permission", "tools", "subagents", "options"]
"required": ["name", "mode", "builtIn", "permission", "tools", "options"]
},
"MCPStatusConnected": {
"type": "object",
Expand Down
70 changes: 0 additions & 70 deletions packages/web/src/content/docs/agents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -381,76 +381,6 @@ You can also use wildcards to control multiple tools at once. For example, to di

---

### Subagents

Control which subagents this agent can invoke via the Task tool with the `subagents` config.

By default, all subagents are available. Set a subagent to `false` to hide it from this agent.

```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"agent": {
"build": {
"subagents": {
"code-reviewer": false
}
}
}
}
```

You can also use wildcards to control multiple subagents at once:

```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"agent": {
"build": {
"subagents": {
"orchestrator-*": false
}
}
}
}
```

Longer patterns take precedence over shorter ones. This allows you to exclude a group while keeping specific exceptions:

```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"agent": {
"build": {
"subagents": {
"orchestrator-*": false,
"orchestrator-fast": true
}
}
}
}
```

You can also configure subagents in Markdown agents:

```markdown title="~/.config/opencode/agent/focused.md"
---
description: Agent with limited subagent access
mode: primary
subagents:
general: true
orchestrator-*: false
---

You are a focused agent with limited subagent access.
```

:::note
Filtered subagents will not appear in the Task tool description and cannot be invoked.
:::

---

### Permissions

You can configure permissions to manage what actions an agent can take. Currently, the permissions for the `edit`, `bash`, and `webfetch` tools can be configured to:
Expand Down