@@ -20,27 +20,26 @@ export const QuestionTool = Tool.defineEffect<typeof parameters, Metadata, Quest
2020 return {
2121 description : DESCRIPTION ,
2222 parameters,
23- async execute ( params : z . infer < typeof parameters > , ctx : Tool . Context < Metadata > ) {
24- const answers = await question
25- . ask ( {
23+ execute : ( params : z . infer < typeof parameters > , ctx : Tool . Context < Metadata > ) =>
24+ Effect . gen ( function * ( ) {
25+ const answers = yield * question . ask ( {
2626 sessionID : ctx . sessionID ,
2727 questions : params . questions ,
2828 tool : ctx . callID ? { messageID : ctx . messageID , callID : ctx . callID } : undefined ,
2929 } )
30- . pipe ( Effect . runPromise )
3130
32- const formatted = params . questions
33- . map ( ( q , i ) => `"${ q . question } "="${ answers [ i ] ?. length ? answers [ i ] . join ( ", " ) : "Unanswered" } "` )
34- . join ( ", " )
31+ const formatted = params . questions
32+ . map ( ( q , i ) => `"${ q . question } "="${ answers [ i ] ?. length ? answers [ i ] . join ( ", " ) : "Unanswered" } "` )
33+ . join ( ", " )
3534
36- return {
37- title : `Asked ${ params . questions . length } question${ params . questions . length > 1 ? "s" : "" } ` ,
38- output : `User has answered your questions: ${ formatted } . You can now continue with the user's answers in mind.` ,
39- metadata : {
40- answers,
41- } ,
42- }
43- } ,
35+ return {
36+ title : `Asked ${ params . questions . length } question${ params . questions . length > 1 ? "s" : "" } ` ,
37+ output : `User has answered your questions: ${ formatted } . You can now continue with the user's answers in mind.` ,
38+ metadata : {
39+ answers,
40+ } ,
41+ }
42+ } ) . pipe ( Effect . runPromise ) ,
4443 }
4544 } ) ,
4645)
0 commit comments