-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: add adaptive thinking type and output_config.effort support #1516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -215,19 +215,33 @@ func ConvertClaudeRequestToCodex(modelName string, inputRawJSON []byte, _ bool) | |
| reasoningEffort := "medium" | ||
| if thinkingConfig := rootResult.Get("thinking"); thinkingConfig.Exists() && thinkingConfig.IsObject() { | ||
| switch thinkingConfig.Get("type").String() { | ||
| case "enabled": | ||
| case "enabled", "adaptive": | ||
| if budgetTokens := thinkingConfig.Get("budget_tokens"); budgetTokens.Exists() { | ||
| budget := int(budgetTokens.Int()) | ||
| if effort, ok := thinking.ConvertBudgetToLevel(budget); ok && effort != "" { | ||
| reasoningEffort = effort | ||
| } | ||
| } else if thinkingConfig.Get("type").String() == "adaptive" { | ||
| // "adaptive" without budget_tokens: default to "high" | ||
| reasoningEffort = "high" | ||
| } | ||
| // "enabled" without budget_tokens: keep default "medium" | ||
| case "disabled": | ||
| if effort, ok := thinking.ConvertBudgetToLevel(0); ok && effort != "" { | ||
| reasoningEffort = effort | ||
| } | ||
| } | ||
| } | ||
| // output_config.effort takes priority (Claude Opus 4.6+ adaptive thinking) | ||
| if effort := rootResult.Get("output_config.effort"); effort.Exists() && effort.String() != "" { | ||
| if mapped := thinking.MapClaudeEffortToLevel(effort.String()); mapped != "" { | ||
| // Cap xhigh to high — Codex only supports low/medium/high | ||
| if mapped == string(thinking.LevelXHigh) { | ||
| mapped = string(thinking.LevelHigh) | ||
| } | ||
| reasoningEffort = mapped | ||
| } | ||
| } | ||
|
Comment on lines
216
to
+244
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a bug in how the I suggest refactoring this block to determine the if thinkingConfig := rootResult.Get("thinking"); thinkingConfig.Exists() && thinkingConfig.IsObject() {
thinkingType := thinkingConfig.Get("type").String()
switch thinkingType {
case "enabled", "adaptive":
if budgetTokens := thinkingConfig.Get("budget_tokens"); budgetTokens.Exists() {
budget := int(budgetTokens.Int())
if effort, ok := thinking.ConvertBudgetToLevel(budget); ok && effort != "" {
reasoningEffort = effort
}
} else if thinkingType == "adaptive" {
reasoningEffort = "high"
}
// "enabled" without budget_tokens keeps default "medium"
case "disabled":
if effort, ok := thinking.ConvertBudgetToLevel(0); ok && effort != "" {
reasoningEffort = effort
}
}
}
// output_config.effort takes priority (Claude Opus 4.6+ adaptive thinking)
if effort := rootResult.Get("output_config.effort"); effort.Exists() && effort.String() != "" {
if mapped := thinking.MapClaudeEffortToLevel(effort.String()); mapped != "" {
reasoningEffort = mapped
}
}
// Cap xhigh to high — Codex only supports low/medium/high
if reasoningEffort == string(thinking.LevelXHigh) {
reasoningEffort = string(thinking.LevelHigh)
} |
||
| template, _ = sjson.Set(template, "reasoning.effort", reasoningEffort) | ||
| template, _ = sjson.Set(template, "reasoning.summary", "auto") | ||
| template, _ = sjson.Set(template, "stream", true) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's significant code duplication for handling Claude's thinking parameters across the Gemini-family translators (
antigravity,gemini-cli, andgemini). This logic is nearly identical in all three files, with the only major difference being the JSON path prefix for setting the configuration.To improve maintainability and reduce redundancy, consider extracting this logic into a shared helper function within the
internal/translator/gemini/commonpackage. This function could take the raw JSON, the output buffer, the path prefix, and theenableThoughtTranslateflag as arguments.This would centralize the logic, making future updates easier and less error-prone.