Open source CapCut alternative.
TypeScript
feat(app): adopt Gemini 3.x thinking_level on hosted and Vertex calls
David Le2fa0d3121e4f
diff --git a/apps/Donkey/Sources/DonkeyAI/GeminiVertexVisionBoxPlanner.swift b/apps/Donkey/Sources/DonkeyAI/GeminiVertexVisionBoxPlanner.swiftindex 7a917793..40179dcf 100644--- a/apps/Donkey/Sources/DonkeyAI/GeminiVertexVisionBoxPlanner.swift+++ b/apps/Donkey/Sources/DonkeyAI/GeminiVertexVisionBoxPlanner.swift@@ -55,10 +55,10 @@ public enum GeminiVertexVisionBoxPlanner {"generationConfig": ["temperature": 0,"responseMimeType": "application/json",- // gemini-3.5-flash is a thinking model; left on, thinking tokens can- // consume the whole budget and starve the JSON output. The raw Vertex- // API takes the nested thinkingConfig.thinkingBudget form.- "thinkingConfig": ["thinkingBudget": 0],+ // gemini-3.5-flash takes thinking_level (the integer thinkingBudget is ignored on 3.x).+ // No maxOutputTokens is set, so the large default leaves ample room for medium thinking+ // plus the small box JSON. Vertex takes the proto enum name (uppercase).+ "thinkingConfig": ["thinkingLevel": "MEDIUM"],"responseSchema": ["type": "object","properties": [diff --git a/apps/Donkey/Sources/DonkeyAI/GeminiVertexVisionPlanner.swift b/apps/Donkey/Sources/DonkeyAI/GeminiVertexVisionPlanner.swiftindex a693b98a..f2494f82 100644--- a/apps/Donkey/Sources/DonkeyAI/GeminiVertexVisionPlanner.swift+++ b/apps/Donkey/Sources/DonkeyAI/GeminiVertexVisionPlanner.swift@@ -79,11 +79,10 @@ public enum GeminiVertexVisionPlanner {"generationConfig": ["temperature": 0,"responseMimeType": "application/json",- // gemini-3.5-flash is a thinking model; left on, thinking tokens- // can consume the whole budget and starve the JSON output (the same- // failure VisionActionPlanner disables thinking to avoid). The raw- // Vertex API takes the nested thinkingConfig.thinkingBudget form.- "thinkingConfig": ["thinkingBudget": 0],+ // gemini-3.5-flash takes thinking_level (the integer thinkingBudget is ignored on 3.x).+ // No maxOutputTokens is set, so the large default leaves ample room for medium thinking+ // plus the small action JSON. Vertex takes the proto enum name (uppercase).+ "thinkingConfig": ["thinkingLevel": "MEDIUM"],"responseSchema": ["type": "object","properties": [diff --git a/apps/Donkey/Sources/DonkeyAI/HostedHarnessRequestUnderstanding.swift b/apps/Donkey/Sources/DonkeyAI/HostedHarnessRequestUnderstanding.swiftindex 9e4c5b03..c464b777 100644--- a/apps/Donkey/Sources/DonkeyAI/HostedHarnessRequestUnderstanding.swift+++ b/apps/Donkey/Sources/DonkeyAI/HostedHarnessRequestUnderstanding.swift@@ -175,8 +175,10 @@ public final class HostedHarnessRequestUnderstanding {metadata: ["source": "hosted-harness-request-understanding", "prompt_version": "harness-request-understanding-v1"],parameters: ["temperature": .number(0),- "max_output_tokens": .number(800),- "thinking_budget": .number(0)+ // Headroom for medium thinking PLUS the JSON understanding; tight caps starve the output.+ "max_output_tokens": .number(2_500),+ // Gemini 3.x honors thinking_level, not the integer thinking_budget (which it ignores).+ "thinking_level": .string("medium")])}diff --git a/apps/Donkey/Sources/DonkeyAI/HostedTextGenerator.swift b/apps/Donkey/Sources/DonkeyAI/HostedTextGenerator.swiftindex ea80759f..f244879d 100644--- a/apps/Donkey/Sources/DonkeyAI/HostedTextGenerator.swift+++ b/apps/Donkey/Sources/DonkeyAI/HostedTextGenerator.swift@@ -39,7 +39,8 @@ public struct HostedTextGenerator: Sendable {parameters: ["temperature": .number(0.4),"max_output_tokens": .number(Double(maxOutputTokens)),- "thinking_budget": .number(0)+ // Gemini 3.x honors thinking_level, not the integer thinking_budget (which it ignores).+ "thinking_level": .string("medium")])let backend = self.backenddiff --git a/apps/Donkey/Sources/DonkeyAI/VisionActionPlanner.swift b/apps/Donkey/Sources/DonkeyAI/VisionActionPlanner.swiftindex cfceef06..5a18a193 100644--- a/apps/Donkey/Sources/DonkeyAI/VisionActionPlanner.swift+++ b/apps/Donkey/Sources/DonkeyAI/VisionActionPlanner.swift@@ -183,8 +183,11 @@ public enum VisionActionPlanner {metadata: ["source": "vision-action-planner", "prompt_version": "vision-action-v1"],parameters: ["temperature": .number(0),- "max_output_tokens": .number(2_000),- "thinking_budget": .number(0) // disable Gemini thinking; thinking tokens otherwise starve the JSON output+ // Headroom for medium thinking PLUS the small action JSON, so thinking can't starve it.+ "max_output_tokens": .number(3_000),+ // Gemini 3.x honors thinking_level, not the integer thinking_budget (which it ignores).+ // The thought summary returns separately from the JSON, so it can't corrupt the action.+ "thinking_level": .string("medium")])}