Jump to solution
Verify

The Fix

pip install pydantic==1.10.16

Based on closed pydantic/pydantic issue #9609 · PR/commit linked

Production note: This usually shows up under retries/timeouts. Treat it as a side-effect risk until you can verify behavior with a canary + real traffic.

Jump to Verify Open PR/Commit
@@ -63,7 +63,9 @@ def evaluate_forwardref(type_: ForwardRef, globalns: Any, localns: Any) -> Any: # Even though it is the right signature for python 3.9, mypy complains with # `error: Too many arguments for "_evaluate" of "ForwardRef"` hence the cast... - return cast(Any, type_)._evaluate(globalns, localns, set()) + # Python 3.13/3.12.4+ made `recursive_guard` a kwarg, so name it explicitly to avoid: + # TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'
repro.py
from langchain_google_vertexai import VertexAI, HarmBlockThreshold, HarmCategory def read(): llm = VertexAI(model_name="gemini-1.0-pro", safety_settings=safety_settings()) def safety_settings() -> dict: return { HarmCategory.HARM_CATEGORY_UNSPECIFIED: HarmBlockThreshold.BLOCK_NONE, HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE, HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_NONE, HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_NONE, HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_NONE, }
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
Option A — Upgrade to fixed release\npip install pydantic==1.10.16\nWhen NOT to use: This fix should not be applied if using a version of Python prior to 3.9.\n\n

Why This Fix Works in Production

  • Trigger: TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'
  • Mechanism: Specifies 'recursive_guard' as a keyword argument in ForwardRef._evaluate to fix a TypeError introduced in Python 3.12.4.
  • Why the fix works: Specifies 'recursive_guard' as a keyword argument in ForwardRef._evaluate to fix a TypeError introduced in Python 3.12.4. (first fixed release: 1.10.16).
Production impact:
  • If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.

Why This Breaks in Prod

  • Shows up under Python 3.9 in real deployments (not just unit tests).
  • Surfaces as: TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'

Proof / Evidence

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“My solution was to downgrade python to version 3.12.3 and it worked properly”
@ellyx13 · 2024-06-08 · source
“For my case (venv with python version 3.12.4), upgrading to the latest version 2.8.2 solved this issue.”
@ruoyiqiao · 2024-08-18 · source
“I am using fastapi and pydantic v1 and got the same error”
@ellyx13 · 2024-06-08 · source
“> My solution was to downgrade python to version 3.12.3 and it worked properly I have 3.12.2 on my local”
@midhun-KAGE-Tech · 2024-06-08 · source

Failure Signature (Search String)

  • TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'

Error Message

Stack trace
error.txt
Error Message ------------- TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'

Minimal Reproduction

repro.py
from langchain_google_vertexai import VertexAI, HarmBlockThreshold, HarmCategory def read(): llm = VertexAI(model_name="gemini-1.0-pro", safety_settings=safety_settings()) def safety_settings() -> dict: return { HarmCategory.HARM_CATEGORY_UNSPECIFIED: HarmBlockThreshold.BLOCK_NONE, HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE, HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_NONE, HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_NONE, HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_NONE, }

Environment

  • Python: 3.9
  • Pydantic: 1

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

pip install pydantic==1.10.16

When NOT to use: This fix should not be applied if using a version of Python prior to 3.9.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

Fix reference: https://github.com/pydantic/pydantic/pull/9612

First fixed release: 1.10.16

Last verified: 2026-02-09. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix should not be applied if using a version of Python prior to 3.9.

Verify Fix

verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.

Did This Fix Work in Your Case?

Quick signal helps us prioritize which fixes to verify and improve.

Prevention

  • Add a CI check that diffs key outputs after upgrades (OpenAPI schema snapshots, JSON payload shapes, CLI output).
  • Upgrade behind a canary and run integration tests against the canary before 100% rollout.

Version Compatibility Table

VersionStatus
1.10.16 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.