Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

fix(llm): disable default thinking for gemini-3.8-flash

Felipe Grilo5151b6af3cd3
diff --git a/crates/ai-memory-llm/src/gemini.rs b/crates/ai-memory-llm/src/gemini.rs
index 56ead252..cdc0894d 100644
--- a/crates/ai-memory-llm/src/gemini.rs
+++ b/crates/ai-memory-llm/src/gemini.rs
@@ -277,9 +277,16 @@ fn default_thinking_config_for(model: &str) -> Option<GeminiThinkingConfig> {
// behaviour unchanged — narrowing 2.5 as well would re-enable its
// default thinking and let hidden thought tokens truncate strict JSON,
// which is the whole reason this function exists.
+ //
+ // 3.8 Flash thinks by default too (229 hidden thought tokens on a short
+ // structured prompt, verified against the live API) and accepts
+ // `thinkingBudget = 0` (HTTP 200, 0 thought tokens, half the latency).
+ // Its `-lite` variant is unverified, so it is excluded the same way as
+ // 3.5's rather than assumed to accept the field.
let is_25_flash = model.contains("gemini-2.5-flash");
let is_35_flash_non_lite = model.contains("gemini-3.5-flash") && !model.contains("-lite");
- if is_25_flash || is_35_flash_non_lite {
+ let is_38_flash_non_lite = model.contains("gemini-3.8-flash") && !model.contains("-lite");
+ if is_25_flash || is_35_flash_non_lite || is_38_flash_non_lite {
return Some(GeminiThinkingConfig { thinking_budget: 0 });
}
None
@@ -637,6 +644,26 @@ mod tests {
assert_thinking_budget_disabled("gemini-3.5-flash");
}
+ #[test]
+ fn build_request_disables_default_thinking_for_38_flash() {
+ assert_thinking_budget_disabled("gemini-3.8-flash");
+ }
+
+ /// 3.8 Flash-Lite has not been verified against the live API, so it keeps
+ /// the conservative 3.5-lite behaviour: omit the field rather than risk an
+ /// HTTP 400 on every call.
+ #[test]
+ fn build_request_omits_thinking_config_for_38_flash_lite() {
+ let lite =
+ GeminiProvider::new(SecretString::from("test-key"), "gemini-3.8-flash-lite").unwrap();
+ let body =
+ serde_json::to_value(lite.build_request(&ChatRequest::user_prompt("x"), None)).unwrap();
+ assert!(
+ body["generationConfig"].get("thinkingConfig").is_none(),
+ "{body}"
+ );
+ }
+
/// `gemini-3.5-flash-lite` rejects `thinkingConfig` with HTTP 400 while
/// `gemini-2.5-flash-lite` accepts it — verified against the live API.
/// The substring match must therefore split the two, or every call on