()
| 14 | }); |
| 15 | |
| 16 | export function buildAskUserQuestionTool(): MakaTool< |
| 17 | { questions: UserQuestion[] }, |
| 18 | UserQuestionResult |
| 19 | > { |
| 20 | return { |
| 21 | name: 'AskUserQuestion', |
| 22 | description: |
| 23 | 'Ask 1–3 bounded multiple-choice questions whose answers are required to continue the current turn. Use ordinary assistant text for open-ended follow-up.', |
| 24 | parameters: z.object({ |
| 25 | questions: z.array(questionSchema).min(1).max(3), |
| 26 | }), |
| 27 | nesting: 'direct_only', |
| 28 | impl: ({ questions }, context) => { |
| 29 | // Unreachable from any ToolRuntime-driven call: ToolRuntime injects |
| 30 | // `askUserQuestion` into every tool context unconditionally, so this |
| 31 | // guard answers only an embedder that assembles its own MakaToolContext. |
| 32 | // It is kept, and worded for a model, because that embedder exists and |
| 33 | // its caller is still a model. |
| 34 | if (!context.askUserQuestion) |
| 35 | throw new Error( |
| 36 | 'AskUserQuestion is not available on this surface, so the user was not asked anything. ' + |
| 37 | 'Retrying will fail the same way — write the question and its options as ordinary reply text and wait for the user to answer.', |
| 38 | ); |
| 39 | return context.askUserQuestion(questions); |
| 40 | }, |
| 41 | }; |
| 42 | } |
no test coverage detected