Unknown model_tokens silently falls back to 8192 and truncates — warning goes to stderr, once per process, and never reaches the result

Author: SilverBulletNeoCreated Jul 28, 2026Updated Jul 31, 2026
Labelsbug

Summary

When a model is not in the token table, the graph warns once to stderr and then proceeds with an 8192-token window. For a model with a 1M-token context this silently truncates every non-trivial page, changing the answer without failing, without appearing in the returned object, and without any indication in execution_info.

Max input tokens for model google_genai/gemini-2.5-flash not found, please specify
the model_tokens parameter in the llm section of the graph configuration.
Using default token size: 8192

Why the default is the problem

A silent 8192 window is a plausible answer generator. The run succeeds, the JSON validates, the fields look reasonable — and the model simply never saw the part of the page that mattered. On a long privacy policy or a services page, the extracted answer flips based on where the truncation landed.

Two properties make it easy to miss:

  • the warning is on stderr, so it vanishes in any batch/worker/async context — I hit this inside a 15-agent pipeline where nothing surfaced it
  • it is emitted once per process, not once per run, so a long job warns on the first URL and stays silent for the remaining hundreds

What I'd suggest, in preference order

  1. Raise when model_tokens is absent for an unknown model, with the message telling the user to set it. Loud beats quietly wrong for something that changes results.
  2. If a hard raise is too breaking, keep the fallback but put it in the result — e.g. execution_info["truncated"] = True plus the effective window — so downstream code can detect it.
  3. Failing both, make the default large rather than small. An over-long prompt fails visibly at the provider; an over-short one fails invisibly.
  4. Independently: gemini-2.5-flash / gemini-flash-latest are worth adding to the token table — Google's current flash line is 1M input.

Related

#1099 / #1002 cover model_tokens being rejected on some provider paths. This is the opposite case: it is accepted, absent, and silently defaulted.

Environment

scrapegraphai fresh from PyPI, Python 3.13, macOS, langchain-google-genai (note: not bundled — installing it is a required extra step for Google backends), Playwright chromium headless.

Happy to open a PR for (1) or (2) if you indicate which you'd accept.

Source: ScrapeGraphAI/Scrapegraph-ai