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.
@@ -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'
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,
}
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
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).
- 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
- GitHub issue: #9609
- Fix PR: https://github.com/pydantic/pydantic/pull/9612
- First fixed release: 1.10.16
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.42
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”
“For my case (venv with python version 3.12.4), upgrading to the latest version 2.8.2 solved this issue.”
“I am using fastapi and pydantic v1 and got the same error”
“> My solution was to downgrade python to version 3.12.3 and it worked properly I have 3.12.2 on my local”
Failure Signature (Search String)
- TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'
Error Message
Stack trace
Error Message
-------------
TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'
Minimal Reproduction
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
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.
When NOT to Use This Fix
- This fix should not be applied if using a version of Python prior to 3.9.
Verify Fix
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
| Version | Status |
|---|---|
| 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.