{"record":{"id":"4f8fcfdb1dae79f8","repo":"Hmbown/CodeWhale","slug":"gemini-model-model-requires-a-thought-signatur","errorCode":null,"errorMessage":"Gemini model `{model}` requires a thought signature to replay tool call `{id}`, but none was captured (the turn predates signature capture, or the provider omitted it). Start a new session before using tools on this route.","messagePattern":"Gemini model `(.+?)` requires a thought signature to replay tool call `(.+?)`, but none was captured \\(the turn predates signature capture, or the provider omitted it\\)\\. Start a new session before using tools on this route\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/client/chat.rs","lineNumber":732,"sourceCode":") -> Result<()> {\n    if !is_google_openai_compat_chat_route(base_url) {\n        return Ok(());\n    }\n    let requires_signatures = google_model_requires_thought_signatures(model);\n    let mut unsigned_call_ids: Vec<&str> = Vec::new();\n    for message in messages {\n        let Some(tool_calls) = message.get(\"tool_calls\").and_then(Value::as_array) else {\n            continue;\n        };\n        for call in tool_calls {\n            let missing = call\n                .pointer(\"/extra_content/google/thought_signature\")\n                .and_then(Value::as_str)\n                .is_none();\n            if missing {\n                let id = call.get(\"id\").and_then(Value::as_str).unwrap_or(\"?\");\n                if requires_signatures {\n                    anyhow::bail!(\n                        \"Gemini model `{model}` requires a thought signature to replay tool call \\\n                         `{id}`, but none was captured (the turn predates signature capture, or \\\n                         the provider omitted it). Start a new session before using tools on \\\n                         this route.\"\n                    );\n                }\n                unsigned_call_ids.push(id);\n            }\n        }\n    }\n    if !unsigned_call_ids.is_empty() {\n        // Bounded: identifiers only, and only the first few of them.\n        let sample = unsigned_call_ids\n            .iter()\n            .take(3)\n            .copied()\n            .collect::<Vec<_>>()\n            .join(\", \");","sourceCodeStart":714,"sourceCodeEnd":750,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/client/chat.rs#L714-L750","documentation":"Gemini models that emit thought signatures require each replayed function call to carry the `thought_signature` captured when the model produced it. During wire-body construction, `validate_google_thought_signature_replay` checks every tool call for `/extra_content/google/thought_signature`; a missing one makes the turn unreplayable on this route, so it bails with guidance to start a new session. Raised in `crates/tui/src/client/chat.rs` around line 732.","triggerScenarios":"Building a chat wire body for a signature-requiring Gemini model where a history message contains a tool call whose stored `extra_content.google.thought_signature` is absent — sessions recorded before signature capture existed, or the provider omitted the signature when generating the call.","commonSituations":"Resuming an old session log created before thought-signature capture shipped; provider dropped the signature for some calls; importing/migrating history from another client that strips the extra_content metadata.","solutions":["Start a new session — old turns without signatures cannot be replayed on this route.","Regenerate the affected turn so a signature is captured and stored.","If history was imported/stripped, re-capture or drop the signature-less tool-call turns from the replayed history.","Confirm the provider actually returned signatures for every tool call in the turn."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"fn replay_safe(call: &Value, requires_signatures: bool) -> Result<(), String> {\n    if requires_signatures\n        && call.pointer(\"/extra_content/google/thought_signature\").and_then(Value::as_str).is_none()\n    {\n        return Err(\"tool call lacks thought signature; start a new session\".into());\n    }\n    Ok(())\n}","typeGuard":"fn has_thought_signature(call: &Value) -> bool {\n    call.pointer(\"/extra_content/google/thought_signature\")\n        .and_then(Value::as_str)\n        .map(|s| !s.is_empty())\n        .unwrap_or(false)\n}","tryCatchPattern":"match build_chat_wire_body(...) {\n    Err(e) if e.to_string().contains(\"thought signature\") => {\n        log::warn!(\"stale session without signatures; starting fresh\");\n        start_new_session();\n    }\n    other => other,\n}","preventionTips":["Migrate or drop sessions recorded before thought-signature capture existed.","Preserve extra_content.google.thought_signature when serializing/importing history.","Drop signature-less tool-call turns from replayed Gemini history.","Verify the provider returned signatures for every tool call."],"tags":["gemini","session","tool-use","state"],"backgroundTag":"invalid-state-transition","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}