I reopened my contract-extraction script one morning after several weeks away from it, and found model="gemini-2.5-pro" sitting in three places. The deprecations page told me what that string would mean from December 1: the same request, answered by a different model. Nothing would break. Something would just quietly change — which is the hardest kind of change to notice.
So here is the headline first. From December 1, 2026, API requests to gemini-2.5-pro are automatically routed to gemini-3.8-flash, and billed at 3.8 Flash rates (checked against Google's deprecations page as of November 29, 2026). AI Studio already hides the 2.5 models, and the API only serves them to users who called them before.
This article collects the five techniques that made long-contract analysis on 2.5 Pro reliable enough for real work. The techniques survive the model change. One assumption does not: that setting temperature=0 keeps answers consistent. I've rewritten that part, and I've also fixed two bugs in my own validation code that were quietly throwing away correct results.
The failure that started all of this is worth keeping, too. The first time I handed over a full contract, the list I got back looked immaculate. Checked against the source, one penalty clause was missing and one section number did not exist. I had trusted the tidy output and postponed the check — that was my mistake, not the model's.
What happens to this code after December 1
| Model ID in your code | Who answers from December 1 | Effect on this article |
|---|---|---|
gemini-2.5-pro | gemini-3.8-flash (auto-routed, billed at 3.8 Flash rates) | Technique 3 rewritten — it relied on temperature |
gemini-2.5-flash | gemini-3.5-flash-lite (same terms) | Matters if you ran Pass 1 on the cheaper model |
gemini-2.5-flash-lite | Not on the deprecation list (as of November) | No reason to rush |
Auto-routing is a grace period, not a migration. I moved the model ID into one constant and started logging which model actually served each request:
import logging
from google import genai
MODEL = "gemini-3.8-flash" # as of Nov 2026 — name the routing target explicitly
client = genai.Client()
log = logging.getLogger("contract")
def call(contents, config):
response = client.models.generate_content(model=MODEL, contents=contents, config=config)
# keep the requested ID and the serving model side by side
log.info("requested=%s served=%s", MODEL, response.model_version)
return responseWith model_version in the log, "did my prompt change or did the model change?" becomes a ten-second question instead of an afternoon. Every snippet below goes through this call helper.
The real problem: pointing, not summarizing
Long-document work in business mostly comes down to three jobs:
- Extracting conditions — termination, price changes, penalties
- Checking consistency — clauses in the same contract that contradict each other
- Detecting changes — what actually changed between an old and new version
None of these is summarization. Quality depends on whether the model can point at where something is written. A long context window and the ability to point accurately at one spot inside it are two different capabilities.
Technique 1: Build the map first, then read narrowly
Before prompting, split the document along its own structure — articles for a contract, agenda items for minutes, headings for a spec. Then read it twice.
Pass 1 (full scan). Send the whole document and ask only for an index: which articles relate to which topic. Short output is fine.
Pass 2 (narrow inspection). Pull out only the articles the index named, and say explicitly, "limit yourself to this excerpt."
On a 180-page contract with 2.5 Pro, a single pass found 7 penalty-related clauses. Two passes found 11. Same model; four misses recovered.
import json
from google.genai import types
JSON_CONFIG = types.GenerateContentConfig(
response_mime_type="application/json",
max_output_tokens=8192, # too small, and the model trims its own list
)
def pass1_index(full_text: str) -> dict:
r = call([
"For the contract below, list the article numbers relevant to each topic.",
"Topics: termination, price_change, penalty, nda",
'Return only JSON shaped like {"penalty": ["Article 12", ...], ...}.',
full_text,
], JSON_CONFIG)
return json.loads(r.text)In JSON mode without a schema, response.parsed can come back empty, so this reads response.text with json.loads. I once lost half an hour to a None right here.
One pass for the map, a second, narrower pass for the detail. Whatever model sits behind the ID, I keep that order.
Technique 2: Require a quote — and normalize before you compare
Faced with a long document, a model is almost too good at plausible summaries. The most reliable brake is a schema in which a direct quote from the source is mandatory.
from typing import Literal
from pydantic import BaseModel
class Finding(BaseModel):
aspect: Literal["termination", "price_change", "penalty", "nda"]
condition: str # summary of the condition
section_id: str # e.g. "第12条第2項" / "Article 12(2)"
source_quote: str # verbatim quote, up to 120 chars
page_hint: int # approximate page
class Findings(BaseModel):
findings: list[Finding]
def pass2_extract(segment: str, cfg=None) -> list[Finding]:
cfg = cfg or types.GenerateContentConfig(
response_mime_type="application/json",
response_schema=Findings,
max_output_tokens=8192,
)
r = call(["List every matching condition in this excerpt. Copy source_quote verbatim.", segment], cfg)
return r.parsed.findingsThat part hasn't changed. What I had wrong was the check afterwards. I used a plain substring test:
# Before: on PDF-extracted text this rejects correct quotes too
def validate(findings, document):
return [f for f in findings if f.source_quote in document]Text pulled from a PDF has line breaks in the middle of sentences, and Japanese documents mix full-width and half-width digits and spaces. The model joins the lines when it quotes, so a correct quote no longer matches byte for byte.
# After: fold the variations away, then compare
import re
import unicodedata
def normalize(s: str) -> str:
s = unicodedata.normalize("NFKC", s) # full-width digits/spaces -> half-width
return re.sub(r"\s+", "", s) # drop line breaks and spaces
def validate(findings, document):
doc = normalize(document)
ok, ng = [], []
for f in findings:
(ok if normalize(f.source_quote) in doc else ng).append(f)
for f in ng:
log.warning("uncited section=%s quote=%s", f.section_id, f.source_quote[:40])
return ok, ngOn my contracts, roughly half of what the old check flagged as "not in the source" turned out to be correct quotes. I return the rejects as ng rather than dropping them, because that list is exactly what a person should look at.
Technique 3: Consistency comes from procedure and cross-checks, not temperature
This section used to say "temperature=0 is the baseline for long-document work." That held reasonably well up to 2.5 Pro. The migration guidance for the 3.x models and gemini-4-argon, however, describes temperature, top_p and top_k as deprecated and ignored (as of November 2026).
The trouble is that nothing errors. Leave temperature=0.0 in place and your code keeps running "pinned" when it isn't. I haven't fully verified how much of that setting 3.8 Flash ignores in my own calls, so I stopped relying on it and use three things instead:
- Spell out the procedure in the prompt: list related articles → extract conditions → check for conflicts
- Set thinking depth with
thinking_levelon 3.x models, rather thanthinking_budget - Read the same input twice and review only the disagreement — where two runs differ is usually where the document itself is ambiguous
cfg = types.GenerateContentConfig(
response_mime_type="application/json",
response_schema=Findings,
max_output_tokens=8192,
thinking_config=types.ThinkingConfig(thinking_level="high"),
)
def stable_extract(segment: str):
a = {(f.section_id, normalize(f.source_quote)) for f in pass2_extract(segment, cfg)}
b = {(f.section_id, normalize(f.source_quote)) for f in pass2_extract(segment, cfg)}
return a & b, a ^ b # found both times / found only onceIt costs two calls, but review got shorter, not longer: I only read the items that appeared once.
Technique 4: Old version first, new version second
When comparing two versions of a contract, order mattered. With the old version first, the model was better at catching clauses that existed before and disappeared. Reversed, it anchored on the new text and missed deletions.
import difflib
def diff_prompt(old: str, new: str) -> list[str]:
line_diff = "\n".join(difflib.unified_diff(old.splitlines(), new.splitlines(), lineterm="", n=0))
return [
"OLD VERSION:\n" + old,
"NEW VERSION:\n" + new,
"Mechanical line diff (for reference):\n" + line_diff,
"List deletions, additions and wording changes separately, quoting both versions for each.",
]Passing a mechanical diff alongside narrows where the model has to look. I let difflib compute the diff and ask the model only to interpret it.
Technique 5: Make every output checkable
Embed facts you can verify: is section_id a real article number, is source_quote really in the source, and page_hint tells a human where to open the PDF.
My old section check had a second bug. Its regex allowed a space in 第12条 第2項, but the model returned 第12条第2項, so correct article numbers were reported as missing.
SECTION_RE = re.compile(r"第\d+条(?:第\d+項)?")
def check_sections(findings, document):
doc = normalize(document)
found = set(SECTION_RE.findall(doc))
found |= {re.match(r"第\d+条", s).group() for s in found} # accept bare "第12条" too
return [f.section_id for f in findings if normalize(f.section_id) not in found]Contracts that write article numbers in kanji (第十二条) will match nothing with this pattern; convert the numerals first or adapt the regex to your documents. If the check suddenly says every section is missing, suspect the regex before the model. For English contracts, swap the pattern for something like Article \d+(\(\d+\))?.
When it goes wrong: a triage table
| Symptom | Likely cause | How to check | Fix |
|---|---|---|---|
| After Dec 1, extraction counts or JSON shape change | gemini-2.5-pro routed to gemini-3.8-flash | Compare served (model_version) with the requested ID in your log | Name the target explicitly; compare outputs on a fixed evaluation set before pinning |
| Answers vary even at temperature 0 | Sampling parameters ignored on 3.x | Change temperature and see whether the output distribution moves at all | Use explicit procedure plus two-run disagreement (Technique 3) |
| Correct quotes rejected as "not in source" | Line breaks, full/half-width characters, spacing | Put a rejected quote next to the source by eye | Compare after normalize (Technique 2) |
| Every section reported as missing | Kanji numerals, or spacing differences | Look at the character right after 「第」 in the source | Adapt the regex (Technique 5) |
| Extraction always plateaus at a small count | max_output_tokens too low; the model trims its list | Check whether the finish reason is the token limit | Raise the limit, split topics into separate calls |
| Bills grow when re-sending the same document | Caching not taking effect | Look for cached-token counts in usage metadata | Put shared content first; use explicit caching where the model supports it (check per model in the official docs) |
Full context, two passes, or retrieval?
| Approach | Fits | Weak spot |
|---|---|---|
| Whole document in one call | Up to ~50 pages when you want the gist | You won't notice individual misses |
| Index → narrow inspection (Technique 1) | Contracts and specs with clear article/heading structure | More calls, more time |
| Chunk and retrieve (RAG) | Hundreds of pages, or the same material queried repeatedly | Misses conflicts that span articles |
To read one contract accurately, I use the two-pass approach; to ask the same material many questions, I use retrieval.
Three misconceptions worth correcting
"If it fits in the context, the model will read it." Fitting and pointing accurately are different things. You only see the misses once you count them.
"Auto-routing means I don't need to touch the code." Routing keeps you running; it doesn't promise the same quality. Google's own changelog asks you to update model strings before December 1 and review the migration guide's breaking changes.
"temperature=0 gives the same answer every time." Even on 2.5, small prompt edits changed results, and on 3.x the setting is ignored. Put consistency in a fixed evaluation set whose diffs you measure.
What I measured — on 2.5 Pro
These are impressions from 2.5 Pro on Japanese contracts of around 180 pages. I haven't re-measured on 3.8 Flash yet.
- Single pass, full text — 20–30% of clauses missed; repeated citations of the same article
- Index + inspection — under 5% missed, almost no duplicates; about 1.7× the processing time
- Mandatory quotes + validation — unmatched quotes fell from over 10% to under 2%
- Old-first diff — deletion recall rose from about 60% to close to 90%
When the model behind the ID changes, I intend to re-run these four on the same documents. Numbers like these only mean something once you've measured them on your own files.
The next wall: chapters that silently disappear
Two passes won't help if a chapter was lost while the PDF was being read — it simply never shows up in the index. I wrote up how I catch that in When a Whole Chapter Vanished From My Long-PDF Summary.
For checking the December 1 routing itself, key by key, see the gemini-2.5-flash "no longer available" 404 and the December 1 auto-routing. And for the habit of logging requested versus served models, what I check first when Flash starts sounding different goes into more detail.
If you do one thing today, pick a single contract and add two pieces: the few lines that log model_version, and the normalize step before your quote check. Whatever changes on the morning of December 1, I'd rather be the one who notices.