Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

chore: upgrade langchain components (#7320)

Steffen Schmitzed01cb7d9167
diff --git a/packages/shared/package.json b/packages/shared/package.json
index 8e5cf3d793..1cbf029a20 100644
--- a/packages/shared/package.json
+++ b/packages/shared/package.json
@@ -62,12 +62,12 @@
"@azure/storage-blob": "^12.26.0",
"@clickhouse/client": "^1.11.2",
"@google-cloud/storage": "^7.15.2",
- "@langchain/anthropic": "^0.3.21",
- "@langchain/aws": "^0.1.10",
- "@langchain/core": "^0.3.57",
- "@langchain/google-genai": "^0.2.10",
- "@langchain/google-vertexai": "^0.2.10",
- "@langchain/openai": "^0.5.12",
+ "@langchain/anthropic": "^0.3.22",
+ "@langchain/aws": "^0.1.11",
+ "@langchain/core": "^0.3.58",
+ "@langchain/google-genai": "^0.2.12",
+ "@langchain/google-vertexai": "^0.2.12",
+ "@langchain/openai": "^0.5.13",
"@opentelemetry/api": ">=1.0.0 <1.10.0",
"@prisma/client": "^6.3.0",
"@react-email/components": "^0.0.42",
@@ -82,7 +82,7 @@
"https-proxy-agent": "^7.0.6",
"ioredis": "^5.4.1",
"kysely": "^0.27.4",
- "langchain": "^0.3.27",
+ "langchain": "^0.3.28",
"langfuse-langchain": "3.37.4",
"lodash": "^4.17.21",
"lossless-json": "^4.0.2",
diff --git a/packages/shared/src/server/llm/fetchLLMCompletion.ts b/packages/shared/src/server/llm/fetchLLMCompletion.ts
index 57db4995e6..4adf8bacf9 100644
--- a/packages/shared/src/server/llm/fetchLLMCompletion.ts
+++ b/packages/shared/src/server/llm/fetchLLMCompletion.ts
@@ -1,6 +1,4 @@
-// We continue to use zod v3 for langchainjs.
-// Corresponding issue report: https://github.com/langchain-ai/langchainjs/issues/8357.
-import { type ZodSchema } from "zod";
+import { type ZodSchema } from "zod/v4";
import { ChatAnthropic } from "@langchain/anthropic";
import { ChatVertexAI } from "@langchain/google-vertexai";
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 08c1d013f5..279767835b 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -60,7 +60,7 @@ importers:
next-auth:
specifier: ^4.24.11
zod:
specifier: ^3.25.62
version: 3.25.62
@@ -158,23 +158,23 @@ importers:
specifier: ^7.15.2
version: 7.15.2
'@langchain/anthropic':
- specifier: ^0.3.21
+ specifier: ^0.3.22
'@langchain/aws':
- specifier: ^0.1.10
+ specifier: ^0.1.11
'@langchain/core':
- specifier: ^0.3.57
+ specifier: ^0.3.58
'@langchain/google-genai':
- specifier: ^0.2.10
+ specifier: ^0.2.12
'@langchain/google-vertexai':
- specifier: ^0.2.10
+ specifier: ^0.2.12
'@langchain/openai':
- specifier: ^0.5.12
+ specifier: ^0.5.13
'@opentelemetry/api':
specifier: '>=1.0.0 <1.10.0'
version: 1.9.0
@@ -218,11 +218,11 @@ importers:
specifier: ^0.27.4
version: 0.27.4
langchain:
- specifier: ^0.3.27
+ specifier: ^0.3.28
langfuse-langchain:
specifier: 3.37.4
lodash:
specifier: ^4.17.21
version: 4.17.21
@@ -231,7 +231,7 @@ importers:
version: 4.0.2
next-auth:
specifier: ^4.24.11
nodemailer:
specifier: ^6.9.15
version: 6.9.15
@@ -371,15 +371,9 @@ importers:
'@hookform/resolvers':
specifier: ^5.1.1
- '@langchain/anthropic':
- specifier: ^0.3.21
'@langchain/core':
- specifier: ^0.3.57
- '@langchain/openai':
- specifier: ^0.5.12
+ specifier: ^0.3.58
'@langfuse/ee':
specifier: workspace:*
version: link:../ee
@@ -624,8 +618,8 @@ importers:
specifier: ^0.27.4
version: 0.27.4
langchain:
- specifier: ^0.3.27
+ specifier: ^0.3.28
lodash:
specifier: ^4.17.21
version: 4.17.21
@@ -637,7 +631,7 @@ importers:
next-auth:
specifier: ^4.24.11
next-query-params:
specifier: ^5.0.1
@@ -2693,20 +2687,20 @@ packages:
peerDependencies:
jsep: ^0.4.0||^1.0.0
- '@langchain/[email protected]':
- resolution: {integrity: sha512-iyVZ9PHcNbABVzWFWtolcDUqHYCEkl1yypRYXE98tTPiNhGo6g/MgKky96TEcOnJ0VNHD6qlzo9LhQl87OplvA==}
+ '@langchain/[email protected]':
+ resolution: {integrity: sha512-3vLuGzWkUC1pGNtu2vyKThiv7jZ063KGYSb2Y89D+NT5iPo5fjmujmgGo5fyoTRpSOUWLgPr7ST+8D35Wmx44g==}
engines: {node: '>=18'}
peerDependencies:
- '@langchain/core': '>=0.3.48 <0.4.0'
+ '@langchain/core': '>=0.3.58 <0.4.0'
- '@langchain/[email protected]':
- resolution: {integrity: sha512-PWA68aPBdLgmOvzsVgVpBec3sfwyCgsx/fpaTsf75k6TfHp4KBzqGGLGzgYo5/QBrInRkxVawJL1eKu4APy2nw==}
+ '@langchain/[email protected]':
+ resolution: {integrity: sha512-JNnEmJaJB5TzcniPYGZi6dlpmZyzeyVsS+Za0Ye1DhCpcNmEiWRy514gVcTPQUEl5EcpIR51B/YyowI7zUzVvg==}
engines: {node: '>=18'}
peerDependencies:
- '@langchain/core': '>=0.3.48 <0.4.0'
+ '@langchain/core': '>=0.3.58 <0.4.0'
- '@langchain/[email protected]':
- resolution: {integrity: sha512-jz28qCTKJmi47b6jqhQ6vYRTG5jRpqhtPQjriRTB5wR8mgvzo6xKs0fG/kExS3ZvM79ytD1npBvgf8i19xOo9Q==}
+ '@langchain/[email protected]':
+ resolution: {integrity: sha512-HLkOtVofgBHefaUae/+2fLNkpMLzEjHSavTmUF0YC7bDa5NPIZGlP80CGrSFXAeJ+WCPd8rIK8K/p6AW94inUQ==}
engines: {node: '>=18'}
'@langchain/[email protected]':
@@ -2721,23 +2715,23 @@ packages:
peerDependencies:
'@langchain/core': '>=0.3.55 <0.4.0'
- '@langchain/[email protected]':
- resolution: {integrity: sha512-kIy0qhu7FAsShNTvuOx8uV+hf7mWk8OzJP5W9mjs1ovAIT1C9WqG1epkhexBfj4DAQfQ6E+m/oGtJ+CVsalspw==}
+ '@langchain/[email protected]':
+ resolution: {integrity: sha512-dVfkNW3uJ2Ing4KAYPTfkdTDIA4FDrik/YK5A5bE8w7drP0J+7g0h2i8D5Mn7dDcyPuX74qd2VG9hWCyGLtZiw==}
engines: {node: '>=18'}
peerDependencies:
- '@langchain/core': '>=0.3.55 <0.4.0'
+ '@langchain/core': '>=0.3.58 <0.4.0'
- '@langchain/[email protected]':
- resolution: {integrity: sha512-XOPUxmsC0vlrtXBrCc3kplb/HbP6D4oj6gR74/vSKqWpgnsm7oDpbyzNg9zYpB9B1Ctps93wQYQzF74JRbOq1g==}
+ '@langchain/[email protected]':
+ resolution: {integrity: sha512-vnorrkFeRQnVMv5xCueQV2rr2xHGkioUdN6n4wexV5n0jLzM5VGwDU1E0Yi6nc43H8g+RwqVlzDE/HYPfqMWuQ==}
engines: {node: '>=18'}
peerDependencies:
'@langchain/core': '>=0.3.55 <0.4.0'
- '@langchain/[email protected]':
- resolution: {integrity: sha512-k7rxBY3ed/HIiMLd6HBqFibsfB0+L6c82H8JgXDqKeyUoACJIi1JaKHXmofmCeF2SBXBU9dog4gEGpHfcUDGUA==}
+ '@langchain/[email protected]':
+ resolution: {integrity: sha512-t5UsO7XYE+DBQlXQ21QK74Y+LH4It20wnENrmueNvxIWTn0nHDIGVmO6wo4rJxbmOOPRQ4l/oAxGRnYU8B8v6w==}
engines: {node: '>=18'}
peerDependencies:
- '@langchain/core': '>=0.3.48 <0.4.0'
+ '@langchain/core': '>=0.3.58 <0.4.0'
'@langchain/[email protected]':
resolution: {integrity: sha512-djI4uw9rlkAb5iMhtLED+xJebDdAG935AdP4eRTB02R7OB/act55Bj9wsskhZsvuyQRpO4O1wQOp85s6T6GWmw==}
@@ -8871,15 +8865,15 @@ packages:
resolution: {integrity: sha512-dyNKv2KRvYOQPLCAOCjjQuCk4YFd33BvGdf/o5bC7FiW+BB6snA81Zt+2wT9QDFzKqxKa5rrOmvlK/anehCcgA==}
engines: {node: '>=14.0.0'}
- resolution: {integrity: sha512-XfOuXetMSpkS11Mt6YJkDmvuSGTMPUsks5DJz4RCZ3y2dcbLkOe5kecjx2SWVJYqQIqcMMwsjsve3/ZjnRe7rQ==}
+ resolution: {integrity: sha512-h4GGlBJNGU/Sj2PipW9kL+ewj7To3c+SnnNKH3HZaVHEqGPMHVB96T1lLjtCLcZCyUfabMr/zFIkLNI4War+Xg==}
engines: {node: '>=18'}
peerDependencies:
'@langchain/anthropic': '*'
'@langchain/aws': '*'
'@langchain/cerebras': '*'
'@langchain/cohere': '*'
- '@langchain/core': '>=0.2.21 <0.4.0'
+ '@langchain/core': '>=0.3.58 <0.4.0'
'@langchain/deepseek': '*'
'@langchain/google-genai': '*'
'@langchain/google-vertexai': '*'
@@ -12113,6 +12107,9 @@ packages:
resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==}
+ resolution: {integrity: sha512-OSm2xTIRfW8CV5/QKgngwmQW/8aPfGdaQFlrGoErlgg/Epm7cjb6K6VEyExfe65a3VybUOnu381edLb0dfJl0g==}
+
resolution: {integrity: sha512-YCxsr4DmhPcrKPC9R1oBHQNlQzlJEyPAId//qTau/vBee9uO8K6prmRq4eMkOyxvBfH4wDPIPdLx9HVMWIY3xA==}
@@ -14706,29 +14703,25 @@ snapshots:
dependencies:
jsep: 1.4.0
dependencies:
'@anthropic-ai/sdk': 0.39.0
- '@langchain/core': 0.3.57([email protected]([email protected]))
+ '@langchain/core': 0.3.58([email protected]([email protected]))
fast-xml-parser: 4.5.0
- zod: 3.25.62
- zod-to-json-schema: 3.23.5([email protected])
transitivePeerDependencies:
- encoding
dependencies:
'@aws-sdk/client-bedrock-agent-runtime': 3.825.0
'@aws-sdk/client-bedrock-runtime': 3.825.0
'@aws-sdk/client-kendra': 3.825.0
'@aws-sdk/credential-provider-node': 3.825.0
- '@langchain/core': 0.3.57([email protected]([email protected]))
- zod: 3.25.62
- zod-to-json-schema: 3.23.5([email protected])
+ '@langchain/core': 0.3.58([email protected]([email protected]))
transitivePeerDependencies:
- aws-crt
dependencies:
'@cfworker/json-schema': 4.1.1
ansi-styles: 5.2.0
@@ -14745,56 +14738,52 @@ snapshots:
transitivePeerDependencies:
- openai
dependencies:
- '@langchain/core': 0.3.57([email protected]([email protected]))
+ '@langchain/core': 0.3.58([email protected]([email protected]))
uuid: 10.0.0
zod-to-json-schema: 3.23.5([email protected])
transitivePeerDependencies:
- zod
dependencies:
- '@langchain/core': 0.3.57([email protected]([email protected]))
- '@langchain/google-common': 0.2.10(@langchain/[email protected]([email protected]([email protected])))([email protected])
+ '@langchain/core': 0.3.58([email protected]([email protected]))
+ '@langchain/google-common': 0.2.10(@langchain/[email protected]([email protected]([email protected])))([email protected])
google-auth-library: 9.15.1
transitivePeerDependencies:
- encoding
- supports-color
- zod
dependencies:
'@google/generative-ai': 0.24.1
- '@langchain/core': 0.3.57([email protected]([email protected]))
+ '@langchain/core': 0.3.58([email protected]([email protected]))
uuid: 11.1.0
- zod-to-json-schema: 3.23.5([email protected])
- transitivePeerDependencies:
- - zod
dependencies:
- '@langchain/core': 0.3.57([email protected]([email protected]))
- '@langchain/google-gauth': 0.2.10(@langchain/[email protected]([email protected]([email protected])))([email protected])
+ '@langchain/core': 0.3.58([email protected]([email protected]))
+ '@langchain/google-gauth': 0.2.10(@langchain/[email protected]([email protected]([email protected])))([email protected])
transitivePeerDependencies:
- encoding
- supports-color
- zod
dependencies:
- '@langchain/core': 0.3.57([email protected]([email protected]))
+ '@langchain/core': 0.3.58([email protected]([email protected]))
js-tiktoken: 1.0.15
- openai: 4.104.0([email protected])
- zod: 3.25.62
- zod-to-json-schema: 3.23.5([email protected])
+ openai: 4.104.0([email protected])
+ zod: 3.25.32
transitivePeerDependencies:
- encoding
- ws
dependencies:
- '@langchain/core': 0.3.57([email protected]([email protected]))
+ '@langchain/core': 0.3.58([email protected]([email protected]))
js-tiktoken: 1.0.15
'@lezer/[email protected]': {}
@@ -15027,7 +15016,7 @@ snapshots:
dependencies:
'@next/[email protected]': {}
@@ -18344,7 +18333,7 @@ snapshots:
'@typescript-eslint/eslint-plugin': 7.3.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])
'@typescript-eslint/parser': 7.12.0([email protected])([email protected])
eslint-config-prettier: 9.1.0([email protected])
- eslint-import-resolver-alias: 1.1.2([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected]))
eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])
eslint-plugin-eslint-comments: 3.2.0([email protected])
@@ -20323,7 +20312,7 @@ snapshots:
eslint: 8.57.0
eslint-plugin-turbo: 1.13.4([email protected])
dependencies:
@@ -20414,7 +20403,7 @@ snapshots:
doctrine: 2.1.0
eslint: 8.57.0
eslint-import-resolver-node: 0.3.9
hasown: 2.0.2
is-core-module: 2.15.1
is-glob: 4.0.3
@@ -20441,7 +20430,7 @@ snapshots:
doctrine: 2.1.0
eslint: 8.57.0
eslint-import-resolver-node: 0.3.9
hasown: 2.0.2
is-core-module: 2.15.1
is-glob: 4.0.3
@@ -22366,11 +22355,11 @@ snapshots:
dependencies:
- '@langchain/core': 0.3.57([email protected]([email protected]))
- '@langchain/openai': 0.5.12(@langchain/[email protected]([email protected]([email protected])))
- '@langchain/textsplitters': 0.1.0(@langchain/[email protected]([email protected]([email protected])))
+ '@langchain/core': 0.3.58([email protected]([email protected]))
+ '@langchain/openai': 0.5.13(@langchain/[email protected]([email protected]([email protected])))
+ '@langchain/textsplitters': 0.1.0(@langchain/[email protected]([email protected]([email protected])))
js-tiktoken: 1.0.15
js-yaml: 4.1.0
jsonpointer: 5.0.1
@@ -22380,12 +22369,11 @@ snapshots:
uuid: 10.0.0
yaml: 2.5.1
zod: 3.25.62
- zod-to-json-schema: 3.23.5([email protected])
optionalDependencies:
- '@langchain/anthropic': 0.3.21(@langchain/[email protected]([email protected]([email protected])))
- '@langchain/aws': 0.1.10(@langchain/[email protected]([email protected]([email protected])))
- '@langchain/google-genai': 0.2.10(@langchain/[email protected]([email protected]([email protected])))([email protected])
- '@langchain/google-vertexai': 0.2.10(@langchain/[email protected]([email protected]([email protected])))([email protected])
+ '@langchain/anthropic': 0.3.22(@langchain/[email protected]([email protected]([email protected])))
+ '@langchain/aws': 0.1.11(@langchain/[email protected]([email protected]([email protected])))
+ '@langchain/google-genai': 0.2.12(@langchain/[email protected]([email protected]([email protected])))
+ '@langchain/google-vertexai': 0.2.12(@langchain/[email protected]([email protected]([email protected])))([email protected])
axios: 1.8.2
cheerio: 1.0.0
handlebars: 4.7.8
@@ -22398,9 +22386,9 @@ snapshots:
dependencies:
mustache: 4.2.0
dependencies:
langfuse: 3.37.4
langfuse-core: 3.37.4
@@ -23157,7 +23145,7 @@ snapshots:
dependencies:
type-fest: 2.19.0
dependencies:
'@babel/runtime': 7.26.0
'@panva/hkdf': 1.1.1
@@ -23425,6 +23413,20 @@ snapshots:
is-docker: 2.2.1
is-wsl: 2.2.0
+ dependencies:
+ '@types/node': 18.19.74
+ '@types/node-fetch': 2.6.12
+ abort-controller: 3.0.0
+ agentkeepalive: 4.6.0
+ form-data-encoder: 1.7.2
+ formdata-node: 4.4.1
+ node-fetch: 2.7.0
+ optionalDependencies:
+ zod: 3.25.32
+ transitivePeerDependencies:
+ - encoding
+
dependencies:
'@types/node': 18.19.74
@@ -23438,6 +23440,7 @@ snapshots:
zod: 3.25.62
transitivePeerDependencies:
- encoding
+ optional: true
@@ -26095,6 +26098,8 @@ snapshots:
+
diff --git a/web/package.json b/web/package.json
index 9930f2b69a..33410aa8e9 100644
--- a/web/package.json
+++ b/web/package.json
@@ -36,9 +36,7 @@
"@headlessui/tailwindcss": "0.2.1",
"@heroicons/react": "^2.1.5",
"@hookform/resolvers": "^5.1.1",
- "@langchain/anthropic": "^0.3.21",
- "@langchain/core": "^0.3.57",
- "@langchain/openai": "^0.5.12",
+ "@langchain/core": "^0.3.58",
"@langfuse/ee": "workspace:*",
"@langfuse/shared": "workspace:*",
"@lezer/highlight": "^1.2.1",
@@ -120,7 +118,7 @@
"ioredis": "^5.4.1",
"ip-address": "^9.0.5",
"kysely": "^0.27.4",
- "langchain": "^0.3.27",
+ "langchain": "^0.3.28",
"lodash": "^4.17.21",
"lucide-react": "^0.462.0",
"next": "^14.2.30",
diff --git a/web/src/features/evals/server/router.ts b/web/src/features/evals/server/router.ts
index fc401aa2fa..0347e70e5f 100644
--- a/web/src/features/evals/server/router.ts
+++ b/web/src/features/evals/server/router.ts
@@ -1,7 +1,4 @@
import { z } from "zod/v4";
-// We continue to use zod v3 for langchainjs.
-// Corresponding issue report: https://github.com/langchain-ai/langchainjs/issues/8357.
-import { z as zv3 } from "zod";
import {
createTRPCRouter,
protectedProjectProcedure,
@@ -835,9 +832,9 @@ export const evalRouter = createTRPCRouter({
adapter: matchingLLMKey.adapter,
...input.modelParams,
},
- structuredOutputSchema: zv3.object({
- score: zv3.string(),
- reasoning: zv3.string(),
+ structuredOutputSchema: z.object({
+ score: z.string(),
+ reasoning: z.string(),
}),
config: matchingLLMKey.config,
})
diff --git a/web/src/features/public-api/components/CreateLLMApiKeyForm.tsx b/web/src/features/public-api/components/CreateLLMApiKeyForm.tsx
index 8df41e73a3..c88157df18 100644
--- a/web/src/features/public-api/components/CreateLLMApiKeyForm.tsx
+++ b/web/src/features/public-api/components/CreateLLMApiKeyForm.tsx
@@ -7,7 +7,7 @@ import {
type LlmApiKeys,
} from "@langfuse/shared";
import { PlusIcon, TrashIcon } from "lucide-react";
-import { z } from "zod";
+import { z } from "zod/v4";
import { Button } from "@/src/components/ui/button";
import {
Form,
diff --git a/worker/src/features/evaluation/evalService.ts b/worker/src/features/evaluation/evalService.ts
index 1fe0f15913..9e1f40bb9a 100644
--- a/worker/src/features/evaluation/evalService.ts
+++ b/worker/src/features/evaluation/evalService.ts
@@ -1,9 +1,6 @@
import { randomUUID } from "crypto";
import { sql } from "kysely";
import { z } from "zod/v4";
-// We continue to use zod v3 for langchainjs.
-// Corresponding issue report: https://github.com/langchain-ai/langchainjs/issues/8357.
-import { z as zv3 } from "zod";
import { JobConfigState } from "@prisma/client";
import {
QueueJobs,
@@ -497,10 +494,10 @@ export const evaluate = async ({
`Evaluating job ${event.jobExecutionId} compiled prompt ${prompt}`,
);
- const parsedOutputSchema = zv3
+ const parsedOutputSchema = z
.object({
- score: zv3.string(),
- reasoning: zv3.string(),
+ score: z.string(),
+ reasoning: z.string(),
})
.parse(template.outputSchema);
@@ -508,9 +505,9 @@ export const evaluate = async ({
throw new InvalidRequestError("Output schema not found");
}
- const evalScoreSchema = zv3.object({
- reasoning: zv3.string().describe(parsedOutputSchema.reasoning),
- score: zv3.number().describe(parsedOutputSchema.score),
+ const evalScoreSchema = z.object({
+ reasoning: z.string().describe(parsedOutputSchema.reasoning),
+ score: z.number().describe(parsedOutputSchema.score),
});
const modelConfig = await DefaultEvalModelService.fetchValidModelConfig(
diff --git a/worker/src/features/utilities.ts b/worker/src/features/utilities.ts
index f511ad1370..6521652927 100644
--- a/worker/src/features/utilities.ts
+++ b/worker/src/features/utilities.ts
@@ -6,10 +6,7 @@ import {
type TraceParams,
} from "@langfuse/shared/src/server";
import { ApiError, LLMApiKeySchema, ZodModelConfig } from "@langfuse/shared";
-import { z } from "zod/v4";
-// We continue to use zod v3 for langchainjs.
-// Corresponding issue report: https://github.com/langchain-ai/langchainjs/issues/8357.
-import { z as zv3, ZodSchema } from "zod";
+import { z, ZodSchema } from "zod/v4";
import { decrypt } from "@langfuse/shared/encryption";
import { tokenCount } from "./tokenisation/usage";
import Handlebars from "handlebars";
@@ -22,7 +19,7 @@ export async function callStructuredLLM<T extends ZodSchema>(
provider: string,
model: string,
structuredOutputSchema: T,
-): Promise<zv3.infer<T>> {
+): Promise<z.infer<T>> {
try {
const { completion } = await fetchLLMCompletion({
streaming: false,