Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(agent): stop Gemini turns hanging on unrecognized thinking config (#7260)

Wolf Mermelsteind8f20c3aa457
diff --git a/crates/agent/src/model/gemini.rs b/crates/agent/src/model/gemini.rs
index aba273cd5d..57cfe2e98b 100644
--- a/crates/agent/src/model/gemini.rs
+++ b/crates/agent/src/model/gemini.rs
@@ -33,11 +33,19 @@ impl<'a, H: HttpClientExt + Clone + 'static> GeminiModel<'a, H> {
/// Ask Gemini to include thought summaries so reasoning deltas reach the
/// stream. Thinking itself is on by default for Gemini 3; this only asks
/// for the summarized thoughts, not a thinking-level override.
+ ///
+ /// Keys are the camelCase names rig deserializes into
+ /// `AdditionalParameters`. A snake_case `generation_config` is not that
+ /// field: it is left on the body as an unknown key, and rig then skips
+ /// `maxOutputTokens` because it only copies `max_tokens` when
+ /// `generationConfig` parsed. The request goes out with thinking on, no
+ /// output cap, and no streamed thoughts, so the turn sits silent until
+ /// the idle timeout.
pub fn thinking_params(&self) -> Option<serde_json::Value> {
Some(serde_json::json!({
- "generation_config": {
- "thinking_config": {
- "include_thoughts": true
+ "generationConfig": {
+ "thinkingConfig": {
+ "includeThoughts": true
}
}
}))
diff --git a/crates/agent/src/model/gemini/test.rs b/crates/agent/src/model/gemini/test.rs
index 285c48b785..641cf06cd7 100644
--- a/crates/agent/src/model/gemini/test.rs
+++ b/crates/agent/src/model/gemini/test.rs
@@ -1,5 +1,6 @@
use super::*;
use crate::model::types::Model;
+use rig_core::providers::gemini::completion::gemini_api_types::AdditionalParameters;
#[test]
fn thinking_params_ask_for_thought_summaries() {
@@ -9,14 +10,24 @@ fn thinking_params_ask_for_thought_summaries() {
.build()
.expect("gemini client");
let gemini = GeminiModel::new(model, Arc::new(client));
+ let params = gemini.thinking_params().expect("thinking params");
+
+ // Rig parses this JSON into AdditionalParameters before it builds the
+ // GenerateContent body. Snake_case keys do not land in generationConfig,
+ // so includeThoughts and the max-token copy both disappear.
+ let parsed: AdditionalParameters =
+ serde_json::from_value(params).expect("thinking params are gemini additional params");
+ let config = parsed
+ .generation_config
+ .expect("generationConfig is recognized");
+ let thinking = config
+ .thinking_config
+ .expect("thinkingConfig is recognized");
+ assert_eq!(thinking.include_thoughts, Some(true));
+ let leftover = parsed.additional_params.unwrap_or(serde_json::json!({}));
assert_eq!(
- gemini.thinking_params(),
- Some(serde_json::json!({
- "generation_config": {
- "thinking_config": {
- "include_thoughts": true
- }
- }
- }))
+ leftover,
+ serde_json::json!({}),
+ "unparsed keys would be sent as unknown Gemini fields"
);
}