diff --git a/packages/cli/src/ui/commands/btwCommand.test.ts b/packages/cli/src/ui/commands/btwCommand.test.ts index 2db053dd8..62df6cb1f 100644 --- a/packages/cli/src/ui/commands/btwCommand.test.ts +++ b/packages/cli/src/ui/commands/btwCommand.test.ts @@ -87,6 +87,28 @@ describe('btwCommand', () => { }); }); + it('should return error when model is not configured', async () => { + const noModelContext = createMockCommandContext({ + services: { + config: { + getGeminiClient: () => ({ + getHistory: mockGetHistory, + generateContent: mockGenerateContent, + }), + getModel: () => '', + }, + }, + }); + + const result = await btwCommand.action!(noModelContext, 'test question'); + + expect(result).toEqual({ + type: 'message', + messageType: 'error', + content: 'No model configured.', + }); + }); + describe('interactive mode', () => { it('should set pending item and add completed item on success', async () => { mockGenerateContent.mockResolvedValue({ @@ -149,7 +171,7 @@ describe('btwCommand', () => { ], }, ], - {}, + { tools: [] }, expect.any(AbortSignal), 'test-model', ); diff --git a/packages/cli/src/ui/commands/btwCommand.ts b/packages/cli/src/ui/commands/btwCommand.ts index 541e03021..8280465f5 100644 --- a/packages/cli/src/ui/commands/btwCommand.ts +++ b/packages/cli/src/ui/commands/btwCommand.ts @@ -45,7 +45,7 @@ async function askBtw( ], }, ], - {}, + { tools: [] }, abortSignal, model, ); @@ -97,6 +97,14 @@ export const btwCommand: SlashCommand = { const geminiClient = config.getGeminiClient(); const model = config.getModel(); + if (!model) { + return { + type: 'message', + messageType: 'error', + content: t('No model configured.'), + }; + } + // ACP mode: return a stream_messages async generator if (executionMode === 'acp') { const messages = async function* () {