From 157c5d77f80571906ad3b5ac5527fa62b84adf23 Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Fri, 10 Apr 2026 09:42:06 -0400 Subject: [PATCH] refactor(tool): convert question tool internals to Effect (#21808) --- packages/opencode/src/tool/question.ts | 29 +++++++++++++------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/opencode/src/tool/question.ts b/packages/opencode/src/tool/question.ts index 23c9b35c89..f7adbadcf7 100644 --- a/packages/opencode/src/tool/question.ts +++ b/packages/opencode/src/tool/question.ts @@ -20,27 +20,26 @@ export const QuestionTool = Tool.defineEffect, ctx: Tool.Context) { - const answers = await question - .ask({ + execute: (params: z.infer, ctx: Tool.Context) => + Effect.gen(function* () { + const answers = yield* question.ask({ sessionID: ctx.sessionID, questions: params.questions, tool: ctx.callID ? { messageID: ctx.messageID, callID: ctx.callID } : undefined, }) - .pipe(Effect.runPromise) - const formatted = params.questions - .map((q, i) => `"${q.question}"="${answers[i]?.length ? answers[i].join(", ") : "Unanswered"}"`) - .join(", ") + const formatted = params.questions + .map((q, i) => `"${q.question}"="${answers[i]?.length ? answers[i].join(", ") : "Unanswered"}"`) + .join(", ") - return { - title: `Asked ${params.questions.length} question${params.questions.length > 1 ? "s" : ""}`, - output: `User has answered your questions: ${formatted}. You can now continue with the user's answers in mind.`, - metadata: { - answers, - }, - } - }, + return { + title: `Asked ${params.questions.length} question${params.questions.length > 1 ? "s" : ""}`, + output: `User has answered your questions: ${formatted}. You can now continue with the user's answers in mind.`, + metadata: { + answers, + }, + } + }).pipe(Effect.runPromise), } }), )