Skip to content

Commit aca7e98

Browse files
fix(gemini-common): Allow reasoning to be turned off by setting maxReasoningTokens to 0. (#8147)
2 parents b7a9cac + f2d4e29 commit aca7e98

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

libs/langchain-google-common/src/utils/gemini.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,10 +1422,8 @@ export function getGeminiAPI(config?: GeminiAPIConfig): GoogleAIAPI {
14221422
}
14231423

14241424
// Add thinking configuration if explicitly set
1425-
if (
1426-
typeof parameters.maxReasoningTokens !== "undefined" &&
1427-
parameters.maxReasoningTokens !== 0
1428-
) {
1425+
// Note that you cannot have thinkingBudget set to 0 and includeThoughts true
1426+
if (typeof parameters.maxReasoningTokens !== "undefined") {
14291427
ret.thinkingConfig = {
14301428
thinkingBudget: parameters.maxReasoningTokens,
14311429
// TODO: Expose this configuration to the user once google fully supports it

libs/langchain-google-webauth/src/tests/chat_models.int.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,12 @@ const testGeminiModelNames = [
357357
apiVersion: "v1",
358358
},
359359
{
360-
modelName: "gemini-2.5-pro-exp-03-25",
360+
modelName: "gemini-2.5-pro-preview-05-06",
361361
platformType: "gai",
362362
apiVersion: "v1beta",
363363
},
364364
{
365-
modelName: "gemini-2.5-pro-exp-03-25",
365+
modelName: "gemini-2.5-pro-preview-05-06",
366366
platformType: "gcp",
367367
apiVersion: "v1",
368368
},
@@ -380,6 +380,7 @@ const testGeminiModelDelay: Record<string, number> = {
380380
"gemini-2.0-flash-exp": 10000,
381381
"gemini-2.0-flash-thinking-exp-1219": 10000,
382382
"gemini-2.5-pro-exp-03-25": 10000,
383+
"gemini-2.5-pro-preview-05-06": 10000,
383384
"gemini-2.5-flash-preview-04-17": 10000,
384385
};
385386

@@ -1007,6 +1008,11 @@ describe.each(testGeminiModelNames)(
10071008
);
10081009
console.log(res);
10091010
expect(res.content).toMatch(/^1\/6/);
1011+
expect(res).toHaveProperty("usage_metadata");
1012+
expect(res.usage_metadata).toHaveProperty("output_token_details");
1013+
expect(res.usage_metadata!.output_token_details).not.toHaveProperty(
1014+
"reasoning"
1015+
);
10101016
});
10111017
}
10121018
);

0 commit comments

Comments
 (0)