GEMINI LABJP
NANOLITE — Nano Banana 2 Lite is here: Google's fastest and most cost-efficient Gemini Image model, made for running lightweight image generation cheaplyOMNIFLASH — Gemini Omni Flash is in public preview, a natively multimodal model that lets enterprises and developers build custom, dynamic video workflowsAGENTS — Managed Agents expand with background: true for async server-side runs and polling, remote MCP server integration, and refreshing credentials across interactionsMEMORY — The Memory Bank IngestEvents API is generally available, decoupling event ingestion from memory generation so you can stream content continuouslyTHROUGHPUT — Provisioned Throughput now lets you submit up to seven pending orders for the same model and regionDEPRECATE — Image generation models shut down on August 17, and the Grok 4.1 family on the Gemini Enterprise Agent Platform on August 20NANOLITE — Nano Banana 2 Lite is here: Google's fastest and most cost-efficient Gemini Image model, made for running lightweight image generation cheaplyOMNIFLASH — Gemini Omni Flash is in public preview, a natively multimodal model that lets enterprises and developers build custom, dynamic video workflowsAGENTS — Managed Agents expand with background: true for async server-side runs and polling, remote MCP server integration, and refreshing credentials across interactionsMEMORY — The Memory Bank IngestEvents API is generally available, decoupling event ingestion from memory generation so you can stream content continuouslyTHROUGHPUT — Provisioned Throughput now lets you submit up to seven pending orders for the same model and regionDEPRECATE — Image generation models shut down on August 17, and the Grok 4.1 family on the Gemini Enterprise Agent Platform on August 20
Articles/API / SDK
API / SDK/2026-05-30Advanced

Preserving Gemini 3 Thought Signatures So Multi-Turn Function Calling Doesn't Degrade

When you build function calling on Gemini 3 thinking models, reasoning quality often drops from the second turn onward. The cause is usually a dropped thought signature. Here is how to keep it and verify the effect.

Gemini API192function calling3thinking7agents9production140

Premium Article

While building an agent that detects AdMob revenue anomalies with Gemini, I ran into a strange behavior. On the first turn it would correctly call a tool to "fetch the eCPM," but from the second turn onward its judgment turned sloppy. It would call only one tool when two were needed, or forget premises it had clearly established a turn earlier.

I assumed it was a prompt problem and rewrote my system instructions many times. The effect was limited. The real cause was that I was discarding the thought signature that Gemini 3 thinking models return, at the moment I rebuilt the conversation history. It is an easy detail to miss unless you read the docs carefully, yet it has an outsized effect on production agent quality. In this article I share what the signature actually is, how to assemble your contents without losing it, and how to measure the difference, in the exact order I worked through it as an indie developer.

What a thought signature actually carries

Gemini 3 thinking models return an encrypted representation of their internal reasoning in a field called thoughtSignature. It is distinct from any human-readable thinking text, and we cannot decrypt or read its contents. Its job is to hand the model a key so that, on the next request, it can reconstruct "how I was thinking a moment ago."

The crucial point is that the signature comes back attached to the function call part. When the model decides to call a tool, the functionCall part carries, as a signature, the reasoning context for why it chose that tool. When you run the tool and return the result, you must include that signature-bearing part in the history as-is. Otherwise the model starts its next round of reasoning having lost the context of why it called the tool in the first place.

That was exactly the "judgment gets sloppy from turn two" symptom I hit. Drop the signature and the model rethinks from scratch each turn, like amnesia, and worse, it restarts from an incomplete state where only part of the context is missing, so quality actually drops.

Why even SDK users fall into this

You might assume the official SDK handles this automatically. It is true that if you use a chat session in the Python or Node SDK and push the model's returned response.candidates[0].content straight back into history, the signature is preserved. The problem is that most production code is not that simple.

My agent broke because I extracted only the function call arguments into my own intermediate representation, then rebuilt "the function call name and args" to push back into history after running the tool. The moment you decompose a part for implementation conveniences, such as cleaner logs or easier retries, the signature falls off. The signature is neither the arguments nor the function name; it is metadata attached to the part. So any time you hand-build { functionCall: { name, args } } yourself, you lose it.

In other words, "it's the SDK, so I'm safe" is the wrong mental model. The real dividing line is whether you push the model's returned content object back into history without modifying it.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
Understand exactly how a missing thought signature lowers tool-selection accuracy on later turns, shown through request JSON diffs
Tell apart a REST implementation that loses signatures from one that keeps them, and the trap of assuming the SDK saves you automatically
Take away a tuning workflow grounded in before/after logs from an AdMob anomaly-detection agent, cutting wasteful re-thinking
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Gemini Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

API / SDK2026-07-04
When Two Managed Agents Fight Over the Same Repo: External Leases and Fencing for Isolated Sandboxes
Every Managed Agents run gets its own isolated sandbox, so a local lock cannot stop two runs from touching the same repo or record. Here is how I serialize them safely with an external lease and a fencing token.
API / SDK2026-06-22
Gemini API on Google Cloud: Diagnosing Production Errors Layer by Layer
Systematically diagnose Gemini API errors in Google Cloud production environments. Covers IAM permissions, Vertex AI vs AI Studio, VPC Service Controls, quota management, service accounts, and multi-region failover with full code examples.
API / SDK2026-06-20
Gemini API Grounding × Structured Output Guide — Turn Web Search Results into Typed JSON Data
Combine Gemini API Grounding with Google Search and Structured Output to extract real-time web information as type-safe JSON data. Practical implementation patterns included.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →