From c2e96f1ffe8e06893b9981acc4364a4eec3feb45 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 15 Dec 2025 19:02:31 +0900 Subject: [PATCH] feat(hooks): restrict background_task for task tool subagents MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - All subagents: disable background_task to prevent recursive spawning - explore/librarian: additionally disable call_omo_agent - Ensures task-invoked subagents use call_omo_agent instead of background_task 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode) --- src/index.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/index.ts b/src/index.ts index 4769086..697fd04 100644 --- a/src/index.ts +++ b/src/index.ts @@ -492,6 +492,18 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => { await nonInteractiveEnv?.["tool.execute.before"](input, output); await commentChecker?.["tool.execute.before"](input, output); + if (input.tool === "task") { + const args = output.args as Record; + const subagentType = args.subagent_type as string; + const isExploreOrLibrarian = ["explore", "librarian"].includes(subagentType); + + args.tools = { + ...(args.tools as Record | undefined), + background_task: false, + ...(isExploreOrLibrarian ? { call_omo_agent: false } : {}), + }; + } + if (input.sessionID === getMainSessionID()) { updateTerminalTitle({ sessionId: input.sessionID,