fix: handle undefined agent in task tool (#1642)

This commit is contained in:
Aiden Cline
2025-08-06 05:16:43 -05:00
committed by GitHub
parent a48274f82b
commit ad10d3a126

View File

@@ -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<string, MessageV2.ToolPart> = {}
const unsub = Bus.subscribe(MessageV2.Event.PartUpdated, async (evt) => {