fix: set Google thinking config by Gemini model version

Uses thinkingLevel for Gemini 3 Flash models
Keeps older Gemini Flash models on thinkingBudget: 0
Updates docs and tests for the new Google request payload
This commit is contained in:
Bohdan Triapitsyn
2026-07-15 12:45:06 +03:00
parent 2b5e9a0221
commit f45bb05b07
3 changed files with 62 additions and 4 deletions
@@ -336,3 +336,59 @@ describe('callSmallModel — custom provider config', () => {
});
});
});
describe('callSmallModel — Google thinking configuration', () => {
let fetchMock;
let originalFetch;
beforeEach(() => {
fetchMock = vi.fn();
originalFetch = globalThis.fetch;
globalThis.fetch = fetchMock;
readConfig.mockReset();
readConfig.mockReturnValue({});
});
afterEach(() => {
globalThis.fetch = originalFetch;
});
const googleResponse = (text) => ({
ok: true,
status: 200,
json: async () => ({ candidates: [{ content: { parts: [{ text }] } }] }),
});
it('uses thinkingLevel for Gemini 3 Flash models', async () => {
fetchMock.mockResolvedValue(googleResponse('generated commit'));
const text = await callSmallModel({
auth: { google: { type: 'api', key: 'google-key' } },
catalog: {},
workingDirectory: '/proj',
providerID: 'google',
modelID: 'gemini-3.1-flash-lite-preview',
prompt: 'generate',
});
expect(text).toBe('generated commit');
const body = JSON.parse(lastCall(fetchMock).init.body);
expect(body.generationConfig.thinkingConfig).toEqual({ thinkingLevel: 'minimal' });
});
it('keeps thinkingBudget disabled for Gemini 2.5 Flash models', async () => {
fetchMock.mockResolvedValue(googleResponse('generated commit'));
await callSmallModel({
auth: { google: { type: 'api', key: 'google-key' } },
catalog: {},
workingDirectory: '/proj',
providerID: 'google',
modelID: 'gemini-2.5-flash-lite',
prompt: 'generate',
});
const body = JSON.parse(lastCall(fetchMock).init.body);
expect(body.generationConfig.thinkingConfig).toEqual({ thinkingBudget: 0 });
});
});