Support for zod@4
in withStructuredOutput – Types Not Inferred Properly
#31706
Closed
weilinzung
announced in
Ideas
Replies: 1 comment
-
langchain-ai/langchainjs#8413 moved as issue |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Checked
Feature request
"langchain": "^0.3.24",
"zod": "^3.25.67",
The current langchain with Zod 3
Motivation
The current implementation of withStructuredOutput in LangChain v0.3.24 works well with zod@3, providing accurate type inference based on the given ZodSchema. However, when using zod@4 (e.g., via modular import zod/v4), the type inference breaks.
Expected (with Zod 3):
Actual (with Zod 4):
This significantly weakens the utility of
withStructuredOutput
, especially in codebases moving to Zod 4 for its modular build and better tree-shaking.Proposal (If applicable)
No response
Beta Was this translation helpful? Give feedback.
All reactions