From ad10d3a1268d41596c508c8b88b3be9a86edfcea Mon Sep 17 00:00:00 2001 From: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Date: Wed, 6 Aug 2025 05:16:43 -0500 Subject: [PATCH] fix: handle undefined agent in task tool (#1642) --- packages/opencode/src/tool/task.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/opencode/src/tool/task.ts b/packages/opencode/src/tool/task.ts index ceec9c1a..0ae0ef79 100644 --- a/packages/opencode/src/tool/task.ts +++ b/packages/opencode/src/tool/task.ts @@ -22,6 +22,7 @@ export const TaskTool = Tool.define("task", async () => { const msg = await Session.getMessage(ctx.sessionID, ctx.messageID) if (msg.info.role !== "assistant") throw new Error("Not an assistant message") 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 messageID = Identifier.ascending("message") const parts: Record = {} const unsub = Bus.subscribe(MessageV2.Event.PartUpdated, async (evt) => {