Skip to content

Commit 227d720

Browse files
authored
pass through reasoning_effort to Google thinkingLevel (#5572)
1 parent 6916e19 commit 227d720

File tree

5 files changed

+28
-23
lines changed

5 files changed

+28
-23
lines changed

CLAUDE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,18 @@ className="bg-background text-foreground border-border"
169169
- Test in both light and dark modes
170170
- when making changes to /packages run the tests npx jest **tests**/ in /packages to make sure nothing else is broken
171171

172+
### TypeScript Type Changes
173+
174+
When modifying TypeScript types (interfaces, type aliases, union types):
175+
176+
1. **Run type checking before committing**: `npx tsc --noEmit` in the relevant package to catch type errors (Jest tests alone won't catch all type mismatches)
177+
2. **Search for related types**: When updating union types (e.g., `"low" | "medium" | "high"`), grep for similar patterns to ensure all related types are updated:
178+
```bash
179+
grep -r "thinkingLevel" packages/ # Find all usages of similar type
180+
```
181+
3. **Check cross-package dependencies**: Types in `/packages/` are often used across multiple packages (llm-mapper, prompts, cost). Verify changes don't break consumers.
182+
4. **Run the full build**: For `/packages/` changes, run `cd web && yarn build` or check Vercel preview to catch type errors across the monorepo.
183+
172184
# Helicone Design System Guidelines
173185

174186
## Core Principles

packages/__tests__/llm-mapper/google-reasoning.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,19 @@ describe("Google Reasoning/Thinking Support", () => {
3636
});
3737
});
3838

39-
it("should map reasoning_effort 'medium' to thinkingLevel 'low'", () => {
39+
it("should pass through reasoning_effort 'medium' as thinkingLevel 'medium'", () => {
4040
const openAIRequest: HeliconeChatCreateParams = {
41-
model: "gemini-3-pro",
41+
model: "gemini-3-flash-preview",
4242
messages: [{ role: "user", content: "Test" }],
4343
reasoning_effort: "medium",
4444
};
4545

4646
const googleRequest = toGoogle(openAIRequest);
4747

48-
// Google only supports low/high, so medium maps to low
48+
// Pass through reasoning_effort directly as thinkingLevel
4949
expect(googleRequest.generationConfig?.thinkingConfig).toEqual({
5050
includeThoughts: true,
51-
thinkingLevel: "low",
51+
thinkingLevel: "medium",
5252
});
5353
});
5454

packages/llm-mapper/transform/providers/openai/request/toGoogle.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -258,16 +258,6 @@ function supportsThinkingLevel(model: string): boolean {
258258
return false;
259259
}
260260

261-
/**
262-
* Maps OpenAI reasoning_effort to Google thinkingLevel.
263-
*/
264-
function mapReasoningEffortToThinkingLevel(
265-
effort: "low" | "medium" | "high"
266-
): "low" | "high" {
267-
// Google only supports "low" and "high", so map "medium" to "low"
268-
return effort === "high" ? "high" : "low";
269-
}
270-
271261
/**
272262
* Builds the Google thinking configuration from OpenAI reasoning parameters.
273263
*
@@ -326,10 +316,9 @@ function buildThinkingConfig(
326316

327317
// Handle reasoning_effort
328318
if (modelSupportsThinkingLevel) {
329-
// Gemini 3+ models: use thinkingLevel
330-
thinkingConfig.thinkingLevel = mapReasoningEffortToThinkingLevel(
331-
reasoningEffort as "low" | "medium" | "high"
332-
);
319+
// Gemini 3+ models: pass through reasoning_effort as thinkingLevel
320+
// Google supports "low", "medium", "high" (Flash also supports "minimal" via reasoning_options)
321+
thinkingConfig.thinkingLevel = reasoningEffort as "low" | "medium" | "high";
333322
} else {
334323
// Gemini 2.5 models: use dynamic thinkingBudget (-1)
335324
thinkingConfig.thinkingBudget = -1;

packages/llm-mapper/transform/types/google.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export type GeminiTool = {
3737

3838
export type GeminiThinkingConfig = {
3939
includeThoughts?: boolean;
40-
thinkingLevel?: "low" | "high";
40+
thinkingLevel?: "minimal" | "low" | "medium" | "high";
4141
thinkingBudget?: number;
4242
};
4343

@@ -87,8 +87,8 @@ export type ChatCompletionMessage =
8787
export interface GoogleReasoningOptions {
8888
/** Token budget for thinking (Gemini 2.5 models) */
8989
budget_tokens?: number;
90-
/** Thinking level (Gemini 3+ models) */
91-
thinking_level?: "low" | "high";
90+
/** Thinking level (Gemini 3+ models): minimal (Flash only), low, medium (Flash only), high */
91+
thinking_level?: "minimal" | "low" | "medium" | "high";
9292
}
9393
// === RESPONSE TYPES ===
9494
export interface GoogleFunctionCall {
@@ -157,10 +157,12 @@ export interface GoogleThinkingConfig {
157157
includeThoughts?: boolean;
158158
/**
159159
* Thinking level for Gemini 3+ models
160+
* - "minimal" for minimal reasoning (Flash only)
160161
* - "low" for faster, less detailed reasoning
162+
* - "medium" for balanced reasoning (Flash only)
161163
* - "high" for more detailed reasoning
162164
*/
163-
thinkingLevel?: "low" | "high";
165+
thinkingLevel?: "minimal" | "low" | "medium" | "high";
164166
/**
165167
* Token budget for thinking (for Gemini 2.5 models)
166168
* - Specific token values (e.g., 1024)

packages/prompts/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,12 @@ export interface HeliconeReasoningOptions {
295295

296296
/**
297297
* Thinking level for Google Gemini 3+ models.
298+
* - "minimal" for minimal thinking (Flash only)
298299
* - "low" for faster, less detailed reasoning
300+
* - "medium" for balanced reasoning (Flash only)
299301
* - "high" for more detailed reasoning
300302
*/
301-
thinking_level?: "low" | "high";
303+
thinking_level?: "minimal" | "low" | "medium" | "high";
302304
};
303305
}
304306

0 commit comments

Comments
 (0)