From 37104ba11d8b960fbbbbdc286b3ee01ac2be2c0a Mon Sep 17 00:00:00 2001 From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> Date: Mon, 23 Nov 2026 18:41:11 +0000 Subject: [PATCH 1/6] Document checkpoint_ns on task ToolMessage artifact (Deep Agents JS) --- src/oss/deepagents/subagents.mdx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/oss/deepagents/subagents.mdx b/src/oss/deepagents/subagents.mdx index f4a0721852..13867e7226 100644 --- a/src/oss/deepagents/subagents.mdx +++ b/src/oss/deepagents/subagents.mdx @@ -514,6 +514,31 @@ The simplest pattern is to iterate `stream.subagents` to track each delegated ta ::: +### Checkpoint namespace on task result + +:::js +When a subagent finishes, the `ToolMessage` returned to the parent carries the checkpoint namespace the subagent saved its checkpoints under in `artifact.checkpoint_ns`. A client can use this namespace to load the finished subagent's checkpoint history directly, without scanning the full thread. + +The model never sees `artifact`; it is metadata for client-side consumption only. + +```javascript +for await (const chunk of await agent.stream(input, config)) { + for (const msg of chunk.messages ?? []) { + if (msg._getType() === "tool" && msg.name === "task" && msg.artifact?.checkpoint_ns) { + console.log("Subagent checkpoint namespace:", msg.artifact.checkpoint_ns); + // Load the subagent's history from this namespace + } + } +} +``` + +When checkpointing is not configured or the subagent did not save any checkpoints, `artifact` is not set on the `ToolMessage`. + + + The `checkpoint_ns` artifact on task results requires `deepagents>=1.16.5`. + +::: + ### LangSmith tracing As your deep agent runs, all runs executed by a subagent or the coordinator will have the agent name in their metadata under the `lc_agent_name` key—for example, `{'lc_agent_name': 'research-agent'}`. This lets you identify and filter runs by subagent in LangSmith. From 7c6170048f724f31002be5029d3d609ab8410c83 Mon Sep 17 00:00:00 2001 From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> Date: Thu, 26 Nov 2026 14:20:28 +0100 Subject: [PATCH 2/6] Fix checkpoint_ns section fencing and sample for Robin review. Move the JS-only heading inside the language fence, and replace the values-mode stream loop with an invoke plus getStateHistory example that defines a checkpointer and thread_id. Co-authored-by: Cursor --- src/oss/deepagents/subagents.mdx | 35 ++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/oss/deepagents/subagents.mdx b/src/oss/deepagents/subagents.mdx index 13867e7226..43b39f67a1 100644 --- a/src/oss/deepagents/subagents.mdx +++ b/src/oss/deepagents/subagents.mdx @@ -514,20 +514,39 @@ The simplest pattern is to iterate `stream.subagents` to track each delegated ta ::: +:::js ### Checkpoint namespace on task result -:::js -When a subagent finishes, the `ToolMessage` returned to the parent carries the checkpoint namespace the subagent saved its checkpoints under in `artifact.checkpoint_ns`. A client can use this namespace to load the finished subagent's checkpoint history directly, without scanning the full thread. +When a subagent finishes, the `ToolMessage` returned to the parent carries the checkpoint namespace in `artifact.checkpoint_ns`. A client can load the finished subagent's checkpoint history from that namespace, without scanning the full thread. The model never sees `artifact`; it is metadata for client-side consumption only. +Checkpointing must be active for the artifact to be set. Pass a checkpointer when you create the agent, and a `thread_id` when you run it: + ```javascript -for await (const chunk of await agent.stream(input, config)) { - for (const msg of chunk.messages ?? []) { - if (msg._getType() === "tool" && msg.name === "task" && msg.artifact?.checkpoint_ns) { - console.log("Subagent checkpoint namespace:", msg.artifact.checkpoint_ns); - // Load the subagent's history from this namespace - } +import { HumanMessage, ToolMessage } from "@langchain/core/messages"; +import { MemorySaver } from "@langchain/langgraph"; +import { createDeepAgent } from "deepagents"; + +const checkpointer = new MemorySaver(); +const agent = await createDeepAgent({ checkpointer /* , subagents: [...] */ }); + +const threadId = "example-thread"; +const result = await agent.invoke( + { messages: [new HumanMessage("Research the topic")] }, + { configurable: { thread_id: threadId } }, +); + +const taskMessage = result.messages.find( + (msg) => ToolMessage.isInstance(msg) && msg.name === "task", +); +const checkpointNs = taskMessage?.artifact?.checkpoint_ns; + +if (checkpointNs) { + for await (const snapshot of agent.getStateHistory({ + configurable: { thread_id: threadId, checkpoint_ns: checkpointNs }, + })) { + console.log(snapshot.values); } } ``` From b86bcf359aca920fff5b78024baa60b07eb271bf Mon Sep 17 00:00:00 2001 From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> Date: Thu, 26 Nov 2026 14:27:31 +0100 Subject: [PATCH 3/6] update --- .../deepagents/subagents-checkpoint-ns.ts | 89 +++++ src/code-samples/package-lock.json | 127 +++--- src/code-samples/package.json | 10 +- src/oss/deepagents/subagents.mdx | 29 +- .../subagents-checkpoint-ns-js.mdx | 365 ++++++++++++++++++ 5 files changed, 525 insertions(+), 95 deletions(-) create mode 100644 src/code-samples/deepagents/subagents-checkpoint-ns.ts create mode 100644 src/snippets/code-samples/subagents-checkpoint-ns-js.mdx diff --git a/src/code-samples/deepagents/subagents-checkpoint-ns.ts b/src/code-samples/deepagents/subagents-checkpoint-ns.ts new file mode 100644 index 0000000000..1ddf78e8e3 --- /dev/null +++ b/src/code-samples/deepagents/subagents-checkpoint-ns.ts @@ -0,0 +1,89 @@ +// :snippet-start: subagents-checkpoint-ns-js +import { ToolMessage } from "langchain"; +import { MemorySaver } from "@langchain/langgraph"; +import { createDeepAgent } from "deepagents"; + +const checkpointer = new MemorySaver(); +const agent = await createDeepAgent({ + model: "openai:gpt-6.1-sol", + checkpointer, + name: "main-agent", + systemPrompt: + "You are a project coordinator with no research knowledge. " + + "For every user request, you must call the task() tool with " + + "subagent_type set to research-agent. Never answer research " + + "questions yourself.", + subagents: [ + { + name: "research-agent", + description: + "Delegate research to this subagent. Give one topic at a time.", + systemPrompt: "You are a great researcher. Return a brief summary.", + }, + ], +}); + +// :remove-start: +if (!agent) throw new Error("agent not created"); +if (!agent.getStateHistory) { + throw new Error("agent is missing getStateHistory"); +} +const openaiKey = process.env.OPENAI_API_KEY ?? ""; +if (!openaiKey.startsWith("sk-")) { + console.log( + "✓ subagents-checkpoint-ns validated (skipped live invoke; OPENAI_API_KEY required)", + ); + process.exit(0); +} +// :remove-end: +const threadId = "example-thread"; +const result = await agent.invoke( + { + messages: [ + { + role: "user", + content: "Research one recent advance in quantum computing.", + }, + ], + }, + { configurable: { thread_id: threadId } }, +); + +const taskMessage = result.messages.find( + (msg) => ToolMessage.isInstance(msg) && msg.name === "task", +); +const checkpointNs = taskMessage?.artifact?.checkpoint_ns; + +if (checkpointNs) { + for await (const snapshot of agent.getStateHistory({ + configurable: { thread_id: threadId, checkpoint_ns: checkpointNs }, + })) { + console.log(snapshot.values); + } +} +// :snippet-end: + +// :remove-start: +if (!taskMessage) { + throw new Error("expected a task ToolMessage from the coordinator"); +} +if (!checkpointNs || typeof checkpointNs !== "string") { + throw new Error( + `expected artifact.checkpoint_ns on the task result, got ${String(checkpointNs)}`, + ); +} + +let historyCount = 0; +for await (const snapshot of agent.getStateHistory({ + configurable: { thread_id: threadId, checkpoint_ns: checkpointNs }, +})) { + if (!snapshot.values) { + throw new Error("expected snapshot.values in subagent history"); + } + historyCount += 1; +} +if (historyCount === 0) { + throw new Error("expected at least one checkpoint in subagent history"); +} +console.log("✓ subagents-checkpoint-ns validated"); +// :remove-end: diff --git a/src/code-samples/package-lock.json b/src/code-samples/package-lock.json index 76cc6e46b3..f3e226ac1c 100644 --- a/src/code-samples/package-lock.json +++ b/src/code-samples/package-lock.json @@ -10,13 +10,13 @@ "license": "ISC", "dependencies": { "@google/genai": "^2.31.0", - "@langchain/anthropic": "^1.5.12", + "@langchain/anthropic": "^1.6.6", "@langchain/classic": "^1.0.0", "@langchain/core": "^1.3.7", "@langchain/daytona": "^0.2.3", "@langchain/google": "^0.2.7", "@langchain/google-genai": "^2.1.30", - "@langchain/langgraph": "^1.4.18", + "@langchain/langgraph": "^1.7.5", "@langchain/langgraph-checkpoint-postgres": "^1.0.1", "@langchain/mcp-adapters": "2.0.1", "@langchain/openai": "^1.8.3", @@ -29,12 +29,12 @@ "@modelcontextprotocol/sdk": "1.32.0", "@modelcontextprotocol/server": "2.4.0", "cheerio": "^1.0.0", - "deepagents": "^1.16.2", + "deepagents": "^1.17.1", "deepagents-acp": "^0.1.15", "dotenv": "^17.4.2", "hono": "^4.12.28", - "langchain": "^1.5.18", - "langsmith": "^0.11.0", + "langchain": "^1.6.8", + "langsmith": "^0.14.0", "managed-deepagents": "^0.9.5", "openai": "^7.45.1", "openevals": "^0.2.3", @@ -57,11 +57,12 @@ } }, "node_modules/@anthropic-ai/sdk": { - "version": "0.122.0", - "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.122.0.tgz", - "integrity": "sha512-GGPNftt0caaz9MDlmNQGHX8855Ojaduyy5pm9Sm1h7HalCn0cWNb5/bweadJF+4yzbal+QL6ztBa09WAAOzLmQ==", - "license": "MIT", + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-1.14.0.tgz", + "integrity": "sha512-nADYXUd5fn9Zgw2nHi1iKyt/kb1UUt1cN3RbdxEI6XjTDTxbx4LLG4GnMrxWyS9GgXQllFOyAKSiFM3joDNK9A==", + "license": "Apache-2.0", "dependencies": { + "@opentelemetry/api": "^1.4.1", "json-schema-to-ts": "^3.1.1", "standardwebhooks": "^1.0.0" }, @@ -423,9 +424,9 @@ } }, "node_modules/@babel/runtime": { - "version": "7.29.10", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.10.tgz", - "integrity": "sha512-NpugTzbKgGrNe45Ui32cN8vCFFMxVtP/9rtfwv0nP5FRDAjvYBxJcLVpYA9mr1jxP6cnIT7x9LUzuDTbWYYNRA==", + "version": "7.29.15", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.15.tgz", + "integrity": "sha512-304gsbbGVmQc+cNGHzwHBlqepYdWLKj3VXCQBGt/EGcV7PUPfKI7kAUNW1FZEOCwlQiLvQjg1JEaAlRQ616h+Q==", "license": "MIT", "engines": { "node": ">=6.9.0" @@ -1162,19 +1163,19 @@ "license": "MIT" }, "node_modules/@langchain/anthropic": { - "version": "1.5.12", - "resolved": "https://registry.npmjs.org/@langchain/anthropic/-/anthropic-1.5.12.tgz", - "integrity": "sha512-tVvI94zAtG6isYxBzL7hlbxfbqjmvx/BqBWAov7v+bABKYz3fZHFI2Io1UI5UzU+h/5SuC1qXUV+JxnaqylJJw==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@langchain/anthropic/-/anthropic-1.6.6.tgz", + "integrity": "sha512-tBsnERCfJsr7GetZYK8esUzvV6rzlvbKK8BqKrzgTuW1TVDnxvtzh7404N0hOcdvW5zTiSr/CkiwNBtR7s8ryw==", "license": "MIT", "dependencies": { - "@anthropic-ai/sdk": "^0.122.0", - "zod": "^3.25.76 || ^4" + "@anthropic-ai/sdk": "^1.7.0", + "zod": "^4.6.6" }, "engines": { "node": ">=20" }, "peerDependencies": { - "@langchain/core": "^1.2.14" + "@langchain/core": "^1.5.0" } }, "node_modules/@langchain/classic": { @@ -1326,28 +1327,28 @@ } }, "node_modules/@langchain/langgraph": { - "version": "1.4.18", - "resolved": "https://registry.npmjs.org/@langchain/langgraph/-/langgraph-1.4.18.tgz", - "integrity": "sha512-yrMMJ9hk2NVMD2xU2WoVrgFawAU6s/RzEl/dX9BhlyxZHazo1wHY35z4K2BIBzTUh4z3giCzrUoqRAqW2CWpWg==", + "version": "1.7.5", + "resolved": "https://registry.npmjs.org/@langchain/langgraph/-/langgraph-1.7.5.tgz", + "integrity": "sha512-HeT0O1aOrOIUXLEER5uEvb4HjuYhYOfLKr2vid2HR+NjRVsHnhTfF+wZdzARTBYvWmP83xJx6ItQOPFN3KcfuQ==", "license": "MIT", "dependencies": { - "@langchain/langgraph-checkpoint": "^1.1.5", - "@langchain/langgraph-sdk": "~1.12.0", - "@langchain/protocol": "^0.0.19", + "@langchain/langgraph-checkpoint": "^1.2.3", + "@langchain/langgraph-sdk": "~1.17.0", + "@langchain/protocol": "^0.0.21", "@standard-schema/spec": "1.1.0" }, "engines": { "node": ">=18" }, "peerDependencies": { - "@langchain/core": "^1.1.48", + "@langchain/core": "^1.3.4", "zod": "^3.25.32 || ^4.2.0" } }, "node_modules/@langchain/langgraph-checkpoint": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/@langchain/langgraph-checkpoint/-/langgraph-checkpoint-1.1.5.tgz", - "integrity": "sha512-BwDwl5VeTOh6CVuiIPgsUgfK51vTJDMSbFcSCUfjJWsl8/DPdK/mbv+ejxJstkSk/BlSPMP4JfXWcN6jD2ea2Q==", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@langchain/langgraph-checkpoint/-/langgraph-checkpoint-1.2.3.tgz", + "integrity": "sha512-7pjMUAA23SgENm4kyrPACmvjh+hVb/dT9nutYlCWEErhZTPbBZe0KWcuAA62ZU+Xqopu7r/wDNxGjRXCrpYFVA==", "license": "MIT", "engines": { "node": ">=18" @@ -1440,18 +1441,18 @@ } }, "node_modules/@langchain/langgraph/node_modules/@langchain/langgraph-sdk": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/@langchain/langgraph-sdk/-/langgraph-sdk-1.12.0.tgz", - "integrity": "sha512-F3AOZjKZRUGmE3FzY+RaVZI6WzXOkwnuF7jqgto6rDPSnO9OdVdYGvwGDi3jjRGf5xLoDtX2dpsR9z5KptU+5A==", + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/@langchain/langgraph-sdk/-/langgraph-sdk-1.17.0.tgz", + "integrity": "sha512-m6fAzU7N5yXyG+9QY3A/92tXiT8KXj2hz2wa0XpC7h6DLg0ynNjaVHeyZPxyAd5ioEw9ylUabreSdE7HrZt5Ag==", "license": "MIT", "dependencies": { - "@langchain/protocol": "^0.0.19", + "@langchain/protocol": "^0.0.21", "@types/json-schema": "^7.0.15", "p-queue": "^9.0.1", "p-retry": "^7.1.1" }, "peerDependencies": { - "@langchain/core": "^1.1.48", + "@langchain/core": "^1.3.2", "react": "^18 || ^19", "react-dom": "^18 || ^19" }, @@ -1465,9 +1466,9 @@ } }, "node_modules/@langchain/langgraph/node_modules/@langchain/protocol": { - "version": "0.0.19", - "resolved": "https://registry.npmjs.org/@langchain/protocol/-/protocol-0.0.19.tgz", - "integrity": "sha512-9hKcRrH7cBX6gfutdfXPoft1OCchHe4FEpALoDJMl5Qu+n/YG5ynZmyu8+8cxORlPwHBoKTxggvXz+76M1yX1Q==", + "version": "0.0.21", + "resolved": "https://registry.npmjs.org/@langchain/protocol/-/protocol-0.0.21.tgz", + "integrity": "sha512-HJS8Cd5GJ437MIrCnbrPHx0FJcluyOk5HdZzD081ap4SBzfWpAj/6AtI7fqpNSMo6VZEoEdaN9fIts8R0XR1AQ==", "license": "MIT" }, "node_modules/@langchain/langgraph/node_modules/eventemitter3": { @@ -1477,9 +1478,9 @@ "license": "MIT" }, "node_modules/@langchain/langgraph/node_modules/p-queue": { - "version": "9.3.3", - "resolved": "https://registry.npmjs.org/p-queue/-/p-queue-9.3.3.tgz", - "integrity": "sha512-NXAOdnEe5FsZJfT4oK84lE1Y5cFFdWlRuOo5tww8DyNMxyRXwn39fIkUtNLKppcPC+UYU/bXujNCUGDv01y7CA==", + "version": "9.3.5", + "resolved": "https://registry.npmjs.org/p-queue/-/p-queue-9.3.5.tgz", + "integrity": "sha512-Lki/zhXFVmDhesBUn/yHRLW9Bte7mE7xoFHzTR8sIomV7a2z+LxYAPkGvdfidNiu4fKSfjtawixxSHcZci5QcQ==", "license": "MIT", "dependencies": { "eventemitter3": "^5.0.4", @@ -3458,9 +3459,9 @@ } }, "node_modules/deepagents": { - "version": "1.16.2", - "resolved": "https://registry.npmjs.org/deepagents/-/deepagents-1.16.2.tgz", - "integrity": "sha512-4+pxGWLkpwcwAY4g8upAWMxMJN0RsZPURlkhCCjIKaxOOmFuC7Y7A0qbcLLJx+nxFDLd/zOYo1tbWiONVGu73g==", + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/deepagents/-/deepagents-1.17.1.tgz", + "integrity": "sha512-vfyF2r/CbexofuVWgAGYjngSDeOlEVnQ5FbXp6j/gur/PgS+tEsKiChE6R5+343y6G0NHFOxInhGKQZL6aL6Tg==", "license": "MIT", "dependencies": { "fast-glob": "^3.3.3", @@ -3469,14 +3470,14 @@ "zod": "^4.3.6" }, "peerDependencies": { - "@langchain/anthropic": "^1.5.12", - "@langchain/core": "^1.3.2", - "@langchain/langgraph": "^1.4.10", - "@langchain/langgraph-checkpoint": "^1.1.5", - "@langchain/langgraph-sdk": "^1.9.23", - "@langchain/openai": "^1.6.2", - "langchain": "^1.5.10", - "langsmith": ">=0.7.1 <0.10.0" + "@langchain/anthropic": "^1.5.13", + "@langchain/core": "^1.3.7", + "@langchain/langgraph": "^1.6.1", + "@langchain/langgraph-checkpoint": "^1.2.0", + "@langchain/langgraph-sdk": "^1.9.23 || ^2.0.1", + "@langchain/openai": "^1.6.3", + "langchain": "^1.6.4", + "langsmith": ">=0.11.0 <1.0.0" }, "peerDependenciesMeta": { "@langchain/anthropic": { @@ -4841,27 +4842,27 @@ } }, "node_modules/langchain": { - "version": "1.5.18", - "resolved": "https://registry.npmjs.org/langchain/-/langchain-1.5.18.tgz", - "integrity": "sha512-JSOQrWvMZ4d7AZH9HXB311cVhGa1nbDVkV5bvIa4WWdxwlHTm0Wi15aGEnutJcs0vW2wTEUk4mAS2ukNHKbIBA==", + "version": "1.6.8", + "resolved": "https://registry.npmjs.org/langchain/-/langchain-1.6.8.tgz", + "integrity": "sha512-sLyuJ69OI39O+8Mtw0PZbc6nN70oJKq1GuM513lJiloa2I/tFU2HDjMh870nA2Qu13Zy7kfVYjswxEFoBSwycA==", "license": "MIT", "dependencies": { - "@langchain/langgraph": "^1.4.18", - "@langchain/langgraph-checkpoint": "^1.1.5", + "@langchain/langgraph": "^1.7.2", + "@langchain/langgraph-checkpoint": "^1.2.2", "langsmith": ">=0.11.0 <1.0.0", - "zod": "^3.25.76 || ^4" + "zod": "^4.6.6" }, "engines": { "node": ">=20" }, "peerDependencies": { - "@langchain/core": "^1.2.18" + "@langchain/core": "^1.5.1" } }, "node_modules/langsmith": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.11.0.tgz", - "integrity": "sha512-NMyaEhfHKAVPdXR8jqP1in4BAr2RhJTmBsH+ZzhvBDTxWUsuaprnJxkRe/3NY5d2+wCaPtzbDK2Myhh6vg2q7w==", + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.14.0.tgz", + "integrity": "sha512-GpOpjx2rfsfKD6A4nnWfG9kxYbLlx9//catR1eCUwW/nMQxj4Mq2OQL7NJO9MQ5ZcGnvgsnUZdxBZLd2JJC1qA==", "license": "MIT", "dependencies": { "p-queue": "6.6.2" @@ -6435,9 +6436,9 @@ } }, "node_modules/standardwebhooks": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/standardwebhooks/-/standardwebhooks-1.1.1.tgz", - "integrity": "sha512-bCbX9ZEyFkWPsRz7Bl3NuQUJohmwGSev/yhr7vhaGPlc4AfIrspIRa6cPTBuI1ItmrTDJ4d/S2hCsfe4+vQGnQ==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/standardwebhooks/-/standardwebhooks-1.3.0.tgz", + "integrity": "sha512-5W9skHjqAm2dlA9wWvglTP+oX47JX4lFXVk1aJV7+TG1snvTR4QXaVgPscEzvOw9GRreeavMwbqEeL+MGhZHCg==", "license": "MIT", "dependencies": { "@stablelib/base64": "^1.0.0", diff --git a/src/code-samples/package.json b/src/code-samples/package.json index 44072541e8..12ca3add94 100644 --- a/src/code-samples/package.json +++ b/src/code-samples/package.json @@ -11,13 +11,13 @@ "license": "ISC", "dependencies": { "@google/genai": "^2.31.0", - "@langchain/anthropic": "^1.5.12", + "@langchain/anthropic": "^1.6.6", "@langchain/classic": "^1.0.0", "@langchain/core": "^1.3.7", "@langchain/daytona": "^0.2.3", "@langchain/google": "^0.2.7", "@langchain/google-genai": "^2.1.30", - "@langchain/langgraph": "^1.4.18", + "@langchain/langgraph": "^1.7.5", "@langchain/langgraph-checkpoint-postgres": "^1.0.1", "@langchain/mcp-adapters": "2.0.1", "@langchain/openai": "^1.8.3", @@ -30,12 +30,12 @@ "@modelcontextprotocol/sdk": "1.32.0", "@modelcontextprotocol/server": "2.4.0", "cheerio": "^1.0.0", - "deepagents": "^1.16.2", + "deepagents": "^1.17.1", "deepagents-acp": "^0.1.15", "dotenv": "^17.4.2", "hono": "^4.12.28", - "langchain": "^1.5.18", - "langsmith": "^0.11.0", + "langchain": "^1.6.8", + "langsmith": "^0.14.0", "managed-deepagents": "^0.9.5", "openai": "^7.45.1", "openevals": "^0.2.3", diff --git a/src/oss/deepagents/subagents.mdx b/src/oss/deepagents/subagents.mdx index 43b39f67a1..28a189f9ab 100644 --- a/src/oss/deepagents/subagents.mdx +++ b/src/oss/deepagents/subagents.mdx @@ -7,6 +7,7 @@ import SubagentBasicPy from '/snippets/code-samples/subagent-basic-py.mdx'; import SubagentBasicJs from '/snippets/code-samples/subagent-basic-js.mdx'; import SubagentStreamProgressPy from '/snippets/code-samples/subagent-stream-progress-py.mdx'; import SubagentStreamProgressJs from '/snippets/code-samples/subagent-stream-progress-js.mdx'; +import SubagentsCheckpointNsJs from '/snippets/code-samples/subagents-checkpoint-ns-js.mdx'; import SubagentsCompiledSubagentPy from '/snippets/code-samples/subagents-compiled-subagent-py.mdx'; import SubagentsCompiledSubagentJs from '/snippets/code-samples/subagents-compiled-subagent-js.mdx'; import ForkedSubagentsBasicPy from '/snippets/code-samples/forked-subagents-basic-py.mdx'; @@ -523,33 +524,7 @@ The model never sees `artifact`; it is metadata for client-side consumption only Checkpointing must be active for the artifact to be set. Pass a checkpointer when you create the agent, and a `thread_id` when you run it: -```javascript -import { HumanMessage, ToolMessage } from "@langchain/core/messages"; -import { MemorySaver } from "@langchain/langgraph"; -import { createDeepAgent } from "deepagents"; - -const checkpointer = new MemorySaver(); -const agent = await createDeepAgent({ checkpointer /* , subagents: [...] */ }); - -const threadId = "example-thread"; -const result = await agent.invoke( - { messages: [new HumanMessage("Research the topic")] }, - { configurable: { thread_id: threadId } }, -); - -const taskMessage = result.messages.find( - (msg) => ToolMessage.isInstance(msg) && msg.name === "task", -); -const checkpointNs = taskMessage?.artifact?.checkpoint_ns; - -if (checkpointNs) { - for await (const snapshot of agent.getStateHistory({ - configurable: { thread_id: threadId, checkpoint_ns: checkpointNs }, - })) { - console.log(snapshot.values); - } -} -``` + When checkpointing is not configured or the subagent did not save any checkpoints, `artifact` is not set on the `ToolMessage`. diff --git a/src/snippets/code-samples/subagents-checkpoint-ns-js.mdx b/src/snippets/code-samples/subagents-checkpoint-ns-js.mdx new file mode 100644 index 0000000000..c55e4df89c --- /dev/null +++ b/src/snippets/code-samples/subagents-checkpoint-ns-js.mdx @@ -0,0 +1,365 @@ + + ```ts Google + import { ToolMessage } from "langchain"; + import { MemorySaver } from "@langchain/langgraph"; + import { createDeepAgent } from "deepagents"; + + const checkpointer = new MemorySaver(); + const agent = await createDeepAgent({ + model: "google:gemini-4-hydrogen", + checkpointer, + name: "main-agent", + systemPrompt: + "You are a project coordinator with no research knowledge. " + + "For every user request, you must call the task() tool with " + + "subagent_type set to research-agent. Never answer research " + + "questions yourself.", + subagents: [ + { + name: "research-agent", + description: + "Delegate research to this subagent. Give one topic at a time.", + systemPrompt: "You are a great researcher. Return a brief summary.", + }, + ], + }); + + const threadId = "example-thread"; + const result = await agent.invoke( + { + messages: [ + { + role: "user", + content: "Research one recent advance in quantum computing.", + }, + ], + }, + { configurable: { thread_id: threadId } }, + ); + + const taskMessage = result.messages.find( + (msg) => ToolMessage.isInstance(msg) && msg.name === "task", + ); + const checkpointNs = taskMessage?.artifact?.checkpoint_ns; + + if (checkpointNs) { + for await (const snapshot of agent.getStateHistory({ + configurable: { thread_id: threadId, checkpoint_ns: checkpointNs }, + })) { + console.log(snapshot.values); + } + } + ``` + + ```ts OpenAI + import { ToolMessage } from "langchain"; + import { MemorySaver } from "@langchain/langgraph"; + import { createDeepAgent } from "deepagents"; + + const checkpointer = new MemorySaver(); + const agent = await createDeepAgent({ + model: "openai:gpt-6.1-sol", + checkpointer, + name: "main-agent", + systemPrompt: + "You are a project coordinator with no research knowledge. " + + "For every user request, you must call the task() tool with " + + "subagent_type set to research-agent. Never answer research " + + "questions yourself.", + subagents: [ + { + name: "research-agent", + description: + "Delegate research to this subagent. Give one topic at a time.", + systemPrompt: "You are a great researcher. Return a brief summary.", + }, + ], + }); + + const threadId = "example-thread"; + const result = await agent.invoke( + { + messages: [ + { + role: "user", + content: "Research one recent advance in quantum computing.", + }, + ], + }, + { configurable: { thread_id: threadId } }, + ); + + const taskMessage = result.messages.find( + (msg) => ToolMessage.isInstance(msg) && msg.name === "task", + ); + const checkpointNs = taskMessage?.artifact?.checkpoint_ns; + + if (checkpointNs) { + for await (const snapshot of agent.getStateHistory({ + configurable: { thread_id: threadId, checkpoint_ns: checkpointNs }, + })) { + console.log(snapshot.values); + } + } + ``` + + ```ts Anthropic + import { ToolMessage } from "langchain"; + import { MemorySaver } from "@langchain/langgraph"; + import { createDeepAgent } from "deepagents"; + + const checkpointer = new MemorySaver(); + const agent = await createDeepAgent({ + model: "anthropic:claude-sonnet-5", + checkpointer, + name: "main-agent", + systemPrompt: + "You are a project coordinator with no research knowledge. " + + "For every user request, you must call the task() tool with " + + "subagent_type set to research-agent. Never answer research " + + "questions yourself.", + subagents: [ + { + name: "research-agent", + description: + "Delegate research to this subagent. Give one topic at a time.", + systemPrompt: "You are a great researcher. Return a brief summary.", + }, + ], + }); + + const threadId = "example-thread"; + const result = await agent.invoke( + { + messages: [ + { + role: "user", + content: "Research one recent advance in quantum computing.", + }, + ], + }, + { configurable: { thread_id: threadId } }, + ); + + const taskMessage = result.messages.find( + (msg) => ToolMessage.isInstance(msg) && msg.name === "task", + ); + const checkpointNs = taskMessage?.artifact?.checkpoint_ns; + + if (checkpointNs) { + for await (const snapshot of agent.getStateHistory({ + configurable: { thread_id: threadId, checkpoint_ns: checkpointNs }, + })) { + console.log(snapshot.values); + } + } + ``` + + ```ts OpenRouter + import { ToolMessage } from "langchain"; + import { MemorySaver } from "@langchain/langgraph"; + import { createDeepAgent } from "deepagents"; + + const checkpointer = new MemorySaver(); + const agent = await createDeepAgent({ + model: "openrouter:z-ai/glm-5.2", + checkpointer, + name: "main-agent", + systemPrompt: + "You are a project coordinator with no research knowledge. " + + "For every user request, you must call the task() tool with " + + "subagent_type set to research-agent. Never answer research " + + "questions yourself.", + subagents: [ + { + name: "research-agent", + description: + "Delegate research to this subagent. Give one topic at a time.", + systemPrompt: "You are a great researcher. Return a brief summary.", + }, + ], + }); + + const threadId = "example-thread"; + const result = await agent.invoke( + { + messages: [ + { + role: "user", + content: "Research one recent advance in quantum computing.", + }, + ], + }, + { configurable: { thread_id: threadId } }, + ); + + const taskMessage = result.messages.find( + (msg) => ToolMessage.isInstance(msg) && msg.name === "task", + ); + const checkpointNs = taskMessage?.artifact?.checkpoint_ns; + + if (checkpointNs) { + for await (const snapshot of agent.getStateHistory({ + configurable: { thread_id: threadId, checkpoint_ns: checkpointNs }, + })) { + console.log(snapshot.values); + } + } + ``` + + ```ts Fireworks + import { ToolMessage } from "langchain"; + import { MemorySaver } from "@langchain/langgraph"; + import { createDeepAgent } from "deepagents"; + + const checkpointer = new MemorySaver(); + const agent = await createDeepAgent({ + model: "fireworks:accounts/fireworks/models/glm-5p2", + checkpointer, + name: "main-agent", + systemPrompt: + "You are a project coordinator with no research knowledge. " + + "For every user request, you must call the task() tool with " + + "subagent_type set to research-agent. Never answer research " + + "questions yourself.", + subagents: [ + { + name: "research-agent", + description: + "Delegate research to this subagent. Give one topic at a time.", + systemPrompt: "You are a great researcher. Return a brief summary.", + }, + ], + }); + + const threadId = "example-thread"; + const result = await agent.invoke( + { + messages: [ + { + role: "user", + content: "Research one recent advance in quantum computing.", + }, + ], + }, + { configurable: { thread_id: threadId } }, + ); + + const taskMessage = result.messages.find( + (msg) => ToolMessage.isInstance(msg) && msg.name === "task", + ); + const checkpointNs = taskMessage?.artifact?.checkpoint_ns; + + if (checkpointNs) { + for await (const snapshot of agent.getStateHistory({ + configurable: { thread_id: threadId, checkpoint_ns: checkpointNs }, + })) { + console.log(snapshot.values); + } + } + ``` + + ```ts Baseten + import { ToolMessage } from "langchain"; + import { MemorySaver } from "@langchain/langgraph"; + import { createDeepAgent } from "deepagents"; + + const checkpointer = new MemorySaver(); + const agent = await createDeepAgent({ + model: "baseten:zai-org/GLM-5.2", + checkpointer, + name: "main-agent", + systemPrompt: + "You are a project coordinator with no research knowledge. " + + "For every user request, you must call the task() tool with " + + "subagent_type set to research-agent. Never answer research " + + "questions yourself.", + subagents: [ + { + name: "research-agent", + description: + "Delegate research to this subagent. Give one topic at a time.", + systemPrompt: "You are a great researcher. Return a brief summary.", + }, + ], + }); + + const threadId = "example-thread"; + const result = await agent.invoke( + { + messages: [ + { + role: "user", + content: "Research one recent advance in quantum computing.", + }, + ], + }, + { configurable: { thread_id: threadId } }, + ); + + const taskMessage = result.messages.find( + (msg) => ToolMessage.isInstance(msg) && msg.name === "task", + ); + const checkpointNs = taskMessage?.artifact?.checkpoint_ns; + + if (checkpointNs) { + for await (const snapshot of agent.getStateHistory({ + configurable: { thread_id: threadId, checkpoint_ns: checkpointNs }, + })) { + console.log(snapshot.values); + } + } + ``` + + ```ts Ollama + import { ToolMessage } from "langchain"; + import { MemorySaver } from "@langchain/langgraph"; + import { createDeepAgent } from "deepagents"; + + const checkpointer = new MemorySaver(); + const agent = await createDeepAgent({ + model: "ollama:north-mini-code-1.0", + checkpointer, + name: "main-agent", + systemPrompt: + "You are a project coordinator with no research knowledge. " + + "For every user request, you must call the task() tool with " + + "subagent_type set to research-agent. Never answer research " + + "questions yourself.", + subagents: [ + { + name: "research-agent", + description: + "Delegate research to this subagent. Give one topic at a time.", + systemPrompt: "You are a great researcher. Return a brief summary.", + }, + ], + }); + + const threadId = "example-thread"; + const result = await agent.invoke( + { + messages: [ + { + role: "user", + content: "Research one recent advance in quantum computing.", + }, + ], + }, + { configurable: { thread_id: threadId } }, + ); + + const taskMessage = result.messages.find( + (msg) => ToolMessage.isInstance(msg) && msg.name === "task", + ); + const checkpointNs = taskMessage?.artifact?.checkpoint_ns; + + if (checkpointNs) { + for await (const snapshot of agent.getStateHistory({ + configurable: { thread_id: threadId, checkpoint_ns: checkpointNs }, + })) { + console.log(snapshot.values); + } + } + ``` + From 20fae193e4e40c5624b6fb170aa69988b933b13b Mon Sep 17 00:00:00 2001 From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> Date: Thu, 26 Nov 2026 14:57:17 +0100 Subject: [PATCH 4/6] simplify --- .../deepagents/subagents-checkpoint-ns.ts | 89 ----- src/code-samples/package-lock.json | 127 +++--- src/code-samples/package.json | 10 +- src/oss/deepagents/subagents.mdx | 19 - .../subagents-checkpoint-ns-js.mdx | 365 ------------------ 5 files changed, 68 insertions(+), 542 deletions(-) delete mode 100644 src/code-samples/deepagents/subagents-checkpoint-ns.ts delete mode 100644 src/snippets/code-samples/subagents-checkpoint-ns-js.mdx diff --git a/src/code-samples/deepagents/subagents-checkpoint-ns.ts b/src/code-samples/deepagents/subagents-checkpoint-ns.ts deleted file mode 100644 index 1ddf78e8e3..0000000000 --- a/src/code-samples/deepagents/subagents-checkpoint-ns.ts +++ /dev/null @@ -1,89 +0,0 @@ -// :snippet-start: subagents-checkpoint-ns-js -import { ToolMessage } from "langchain"; -import { MemorySaver } from "@langchain/langgraph"; -import { createDeepAgent } from "deepagents"; - -const checkpointer = new MemorySaver(); -const agent = await createDeepAgent({ - model: "openai:gpt-6.1-sol", - checkpointer, - name: "main-agent", - systemPrompt: - "You are a project coordinator with no research knowledge. " + - "For every user request, you must call the task() tool with " + - "subagent_type set to research-agent. Never answer research " + - "questions yourself.", - subagents: [ - { - name: "research-agent", - description: - "Delegate research to this subagent. Give one topic at a time.", - systemPrompt: "You are a great researcher. Return a brief summary.", - }, - ], -}); - -// :remove-start: -if (!agent) throw new Error("agent not created"); -if (!agent.getStateHistory) { - throw new Error("agent is missing getStateHistory"); -} -const openaiKey = process.env.OPENAI_API_KEY ?? ""; -if (!openaiKey.startsWith("sk-")) { - console.log( - "✓ subagents-checkpoint-ns validated (skipped live invoke; OPENAI_API_KEY required)", - ); - process.exit(0); -} -// :remove-end: -const threadId = "example-thread"; -const result = await agent.invoke( - { - messages: [ - { - role: "user", - content: "Research one recent advance in quantum computing.", - }, - ], - }, - { configurable: { thread_id: threadId } }, -); - -const taskMessage = result.messages.find( - (msg) => ToolMessage.isInstance(msg) && msg.name === "task", -); -const checkpointNs = taskMessage?.artifact?.checkpoint_ns; - -if (checkpointNs) { - for await (const snapshot of agent.getStateHistory({ - configurable: { thread_id: threadId, checkpoint_ns: checkpointNs }, - })) { - console.log(snapshot.values); - } -} -// :snippet-end: - -// :remove-start: -if (!taskMessage) { - throw new Error("expected a task ToolMessage from the coordinator"); -} -if (!checkpointNs || typeof checkpointNs !== "string") { - throw new Error( - `expected artifact.checkpoint_ns on the task result, got ${String(checkpointNs)}`, - ); -} - -let historyCount = 0; -for await (const snapshot of agent.getStateHistory({ - configurable: { thread_id: threadId, checkpoint_ns: checkpointNs }, -})) { - if (!snapshot.values) { - throw new Error("expected snapshot.values in subagent history"); - } - historyCount += 1; -} -if (historyCount === 0) { - throw new Error("expected at least one checkpoint in subagent history"); -} -console.log("✓ subagents-checkpoint-ns validated"); -// :remove-end: diff --git a/src/code-samples/package-lock.json b/src/code-samples/package-lock.json index f3e226ac1c..76cc6e46b3 100644 --- a/src/code-samples/package-lock.json +++ b/src/code-samples/package-lock.json @@ -10,13 +10,13 @@ "license": "ISC", "dependencies": { "@google/genai": "^2.31.0", - "@langchain/anthropic": "^1.6.6", + "@langchain/anthropic": "^1.5.12", "@langchain/classic": "^1.0.0", "@langchain/core": "^1.3.7", "@langchain/daytona": "^0.2.3", "@langchain/google": "^0.2.7", "@langchain/google-genai": "^2.1.30", - "@langchain/langgraph": "^1.7.5", + "@langchain/langgraph": "^1.4.18", "@langchain/langgraph-checkpoint-postgres": "^1.0.1", "@langchain/mcp-adapters": "2.0.1", "@langchain/openai": "^1.8.3", @@ -29,12 +29,12 @@ "@modelcontextprotocol/sdk": "1.32.0", "@modelcontextprotocol/server": "2.4.0", "cheerio": "^1.0.0", - "deepagents": "^1.17.1", + "deepagents": "^1.16.2", "deepagents-acp": "^0.1.15", "dotenv": "^17.4.2", "hono": "^4.12.28", - "langchain": "^1.6.8", - "langsmith": "^0.14.0", + "langchain": "^1.5.18", + "langsmith": "^0.11.0", "managed-deepagents": "^0.9.5", "openai": "^7.45.1", "openevals": "^0.2.3", @@ -57,12 +57,11 @@ } }, "node_modules/@anthropic-ai/sdk": { - "version": "1.14.0", - "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-1.14.0.tgz", - "integrity": "sha512-nADYXUd5fn9Zgw2nHi1iKyt/kb1UUt1cN3RbdxEI6XjTDTxbx4LLG4GnMrxWyS9GgXQllFOyAKSiFM3joDNK9A==", - "license": "Apache-2.0", + "version": "0.122.0", + "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.122.0.tgz", + "integrity": "sha512-GGPNftt0caaz9MDlmNQGHX8855Ojaduyy5pm9Sm1h7HalCn0cWNb5/bweadJF+4yzbal+QL6ztBa09WAAOzLmQ==", + "license": "MIT", "dependencies": { - "@opentelemetry/api": "^1.4.1", "json-schema-to-ts": "^3.1.1", "standardwebhooks": "^1.0.0" }, @@ -424,9 +423,9 @@ } }, "node_modules/@babel/runtime": { - "version": "7.29.15", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.15.tgz", - "integrity": "sha512-304gsbbGVmQc+cNGHzwHBlqepYdWLKj3VXCQBGt/EGcV7PUPfKI7kAUNW1FZEOCwlQiLvQjg1JEaAlRQ616h+Q==", + "version": "7.29.10", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.10.tgz", + "integrity": "sha512-NpugTzbKgGrNe45Ui32cN8vCFFMxVtP/9rtfwv0nP5FRDAjvYBxJcLVpYA9mr1jxP6cnIT7x9LUzuDTbWYYNRA==", "license": "MIT", "engines": { "node": ">=6.9.0" @@ -1163,19 +1162,19 @@ "license": "MIT" }, "node_modules/@langchain/anthropic": { - "version": "1.6.6", - "resolved": "https://registry.npmjs.org/@langchain/anthropic/-/anthropic-1.6.6.tgz", - "integrity": "sha512-tBsnERCfJsr7GetZYK8esUzvV6rzlvbKK8BqKrzgTuW1TVDnxvtzh7404N0hOcdvW5zTiSr/CkiwNBtR7s8ryw==", + "version": "1.5.12", + "resolved": "https://registry.npmjs.org/@langchain/anthropic/-/anthropic-1.5.12.tgz", + "integrity": "sha512-tVvI94zAtG6isYxBzL7hlbxfbqjmvx/BqBWAov7v+bABKYz3fZHFI2Io1UI5UzU+h/5SuC1qXUV+JxnaqylJJw==", "license": "MIT", "dependencies": { - "@anthropic-ai/sdk": "^1.7.0", - "zod": "^4.6.6" + "@anthropic-ai/sdk": "^0.122.0", + "zod": "^3.25.76 || ^4" }, "engines": { "node": ">=20" }, "peerDependencies": { - "@langchain/core": "^1.5.0" + "@langchain/core": "^1.2.14" } }, "node_modules/@langchain/classic": { @@ -1327,28 +1326,28 @@ } }, "node_modules/@langchain/langgraph": { - "version": "1.7.5", - "resolved": "https://registry.npmjs.org/@langchain/langgraph/-/langgraph-1.7.5.tgz", - "integrity": "sha512-HeT0O1aOrOIUXLEER5uEvb4HjuYhYOfLKr2vid2HR+NjRVsHnhTfF+wZdzARTBYvWmP83xJx6ItQOPFN3KcfuQ==", + "version": "1.4.18", + "resolved": "https://registry.npmjs.org/@langchain/langgraph/-/langgraph-1.4.18.tgz", + "integrity": "sha512-yrMMJ9hk2NVMD2xU2WoVrgFawAU6s/RzEl/dX9BhlyxZHazo1wHY35z4K2BIBzTUh4z3giCzrUoqRAqW2CWpWg==", "license": "MIT", "dependencies": { - "@langchain/langgraph-checkpoint": "^1.2.3", - "@langchain/langgraph-sdk": "~1.17.0", - "@langchain/protocol": "^0.0.21", + "@langchain/langgraph-checkpoint": "^1.1.5", + "@langchain/langgraph-sdk": "~1.12.0", + "@langchain/protocol": "^0.0.19", "@standard-schema/spec": "1.1.0" }, "engines": { "node": ">=18" }, "peerDependencies": { - "@langchain/core": "^1.3.4", + "@langchain/core": "^1.1.48", "zod": "^3.25.32 || ^4.2.0" } }, "node_modules/@langchain/langgraph-checkpoint": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/@langchain/langgraph-checkpoint/-/langgraph-checkpoint-1.2.3.tgz", - "integrity": "sha512-7pjMUAA23SgENm4kyrPACmvjh+hVb/dT9nutYlCWEErhZTPbBZe0KWcuAA62ZU+Xqopu7r/wDNxGjRXCrpYFVA==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@langchain/langgraph-checkpoint/-/langgraph-checkpoint-1.1.5.tgz", + "integrity": "sha512-BwDwl5VeTOh6CVuiIPgsUgfK51vTJDMSbFcSCUfjJWsl8/DPdK/mbv+ejxJstkSk/BlSPMP4JfXWcN6jD2ea2Q==", "license": "MIT", "engines": { "node": ">=18" @@ -1441,18 +1440,18 @@ } }, "node_modules/@langchain/langgraph/node_modules/@langchain/langgraph-sdk": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/@langchain/langgraph-sdk/-/langgraph-sdk-1.17.0.tgz", - "integrity": "sha512-m6fAzU7N5yXyG+9QY3A/92tXiT8KXj2hz2wa0XpC7h6DLg0ynNjaVHeyZPxyAd5ioEw9ylUabreSdE7HrZt5Ag==", + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/@langchain/langgraph-sdk/-/langgraph-sdk-1.12.0.tgz", + "integrity": "sha512-F3AOZjKZRUGmE3FzY+RaVZI6WzXOkwnuF7jqgto6rDPSnO9OdVdYGvwGDi3jjRGf5xLoDtX2dpsR9z5KptU+5A==", "license": "MIT", "dependencies": { - "@langchain/protocol": "^0.0.21", + "@langchain/protocol": "^0.0.19", "@types/json-schema": "^7.0.15", "p-queue": "^9.0.1", "p-retry": "^7.1.1" }, "peerDependencies": { - "@langchain/core": "^1.3.2", + "@langchain/core": "^1.1.48", "react": "^18 || ^19", "react-dom": "^18 || ^19" }, @@ -1466,9 +1465,9 @@ } }, "node_modules/@langchain/langgraph/node_modules/@langchain/protocol": { - "version": "0.0.21", - "resolved": "https://registry.npmjs.org/@langchain/protocol/-/protocol-0.0.21.tgz", - "integrity": "sha512-HJS8Cd5GJ437MIrCnbrPHx0FJcluyOk5HdZzD081ap4SBzfWpAj/6AtI7fqpNSMo6VZEoEdaN9fIts8R0XR1AQ==", + "version": "0.0.19", + "resolved": "https://registry.npmjs.org/@langchain/protocol/-/protocol-0.0.19.tgz", + "integrity": "sha512-9hKcRrH7cBX6gfutdfXPoft1OCchHe4FEpALoDJMl5Qu+n/YG5ynZmyu8+8cxORlPwHBoKTxggvXz+76M1yX1Q==", "license": "MIT" }, "node_modules/@langchain/langgraph/node_modules/eventemitter3": { @@ -1478,9 +1477,9 @@ "license": "MIT" }, "node_modules/@langchain/langgraph/node_modules/p-queue": { - "version": "9.3.5", - "resolved": "https://registry.npmjs.org/p-queue/-/p-queue-9.3.5.tgz", - "integrity": "sha512-Lki/zhXFVmDhesBUn/yHRLW9Bte7mE7xoFHzTR8sIomV7a2z+LxYAPkGvdfidNiu4fKSfjtawixxSHcZci5QcQ==", + "version": "9.3.3", + "resolved": "https://registry.npmjs.org/p-queue/-/p-queue-9.3.3.tgz", + "integrity": "sha512-NXAOdnEe5FsZJfT4oK84lE1Y5cFFdWlRuOo5tww8DyNMxyRXwn39fIkUtNLKppcPC+UYU/bXujNCUGDv01y7CA==", "license": "MIT", "dependencies": { "eventemitter3": "^5.0.4", @@ -3459,9 +3458,9 @@ } }, "node_modules/deepagents": { - "version": "1.17.1", - "resolved": "https://registry.npmjs.org/deepagents/-/deepagents-1.17.1.tgz", - "integrity": "sha512-vfyF2r/CbexofuVWgAGYjngSDeOlEVnQ5FbXp6j/gur/PgS+tEsKiChE6R5+343y6G0NHFOxInhGKQZL6aL6Tg==", + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/deepagents/-/deepagents-1.16.2.tgz", + "integrity": "sha512-4+pxGWLkpwcwAY4g8upAWMxMJN0RsZPURlkhCCjIKaxOOmFuC7Y7A0qbcLLJx+nxFDLd/zOYo1tbWiONVGu73g==", "license": "MIT", "dependencies": { "fast-glob": "^3.3.3", @@ -3470,14 +3469,14 @@ "zod": "^4.3.6" }, "peerDependencies": { - "@langchain/anthropic": "^1.5.13", - "@langchain/core": "^1.3.7", - "@langchain/langgraph": "^1.6.1", - "@langchain/langgraph-checkpoint": "^1.2.0", - "@langchain/langgraph-sdk": "^1.9.23 || ^2.0.1", - "@langchain/openai": "^1.6.3", - "langchain": "^1.6.4", - "langsmith": ">=0.11.0 <1.0.0" + "@langchain/anthropic": "^1.5.12", + "@langchain/core": "^1.3.2", + "@langchain/langgraph": "^1.4.10", + "@langchain/langgraph-checkpoint": "^1.1.5", + "@langchain/langgraph-sdk": "^1.9.23", + "@langchain/openai": "^1.6.2", + "langchain": "^1.5.10", + "langsmith": ">=0.7.1 <0.10.0" }, "peerDependenciesMeta": { "@langchain/anthropic": { @@ -4842,27 +4841,27 @@ } }, "node_modules/langchain": { - "version": "1.6.8", - "resolved": "https://registry.npmjs.org/langchain/-/langchain-1.6.8.tgz", - "integrity": "sha512-sLyuJ69OI39O+8Mtw0PZbc6nN70oJKq1GuM513lJiloa2I/tFU2HDjMh870nA2Qu13Zy7kfVYjswxEFoBSwycA==", + "version": "1.5.18", + "resolved": "https://registry.npmjs.org/langchain/-/langchain-1.5.18.tgz", + "integrity": "sha512-JSOQrWvMZ4d7AZH9HXB311cVhGa1nbDVkV5bvIa4WWdxwlHTm0Wi15aGEnutJcs0vW2wTEUk4mAS2ukNHKbIBA==", "license": "MIT", "dependencies": { - "@langchain/langgraph": "^1.7.2", - "@langchain/langgraph-checkpoint": "^1.2.2", + "@langchain/langgraph": "^1.4.18", + "@langchain/langgraph-checkpoint": "^1.1.5", "langsmith": ">=0.11.0 <1.0.0", - "zod": "^4.6.6" + "zod": "^3.25.76 || ^4" }, "engines": { "node": ">=20" }, "peerDependencies": { - "@langchain/core": "^1.5.1" + "@langchain/core": "^1.2.18" } }, "node_modules/langsmith": { - "version": "0.14.0", - "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.14.0.tgz", - "integrity": "sha512-GpOpjx2rfsfKD6A4nnWfG9kxYbLlx9//catR1eCUwW/nMQxj4Mq2OQL7NJO9MQ5ZcGnvgsnUZdxBZLd2JJC1qA==", + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.11.0.tgz", + "integrity": "sha512-NMyaEhfHKAVPdXR8jqP1in4BAr2RhJTmBsH+ZzhvBDTxWUsuaprnJxkRe/3NY5d2+wCaPtzbDK2Myhh6vg2q7w==", "license": "MIT", "dependencies": { "p-queue": "6.6.2" @@ -6436,9 +6435,9 @@ } }, "node_modules/standardwebhooks": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/standardwebhooks/-/standardwebhooks-1.3.0.tgz", - "integrity": "sha512-5W9skHjqAm2dlA9wWvglTP+oX47JX4lFXVk1aJV7+TG1snvTR4QXaVgPscEzvOw9GRreeavMwbqEeL+MGhZHCg==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/standardwebhooks/-/standardwebhooks-1.1.1.tgz", + "integrity": "sha512-bCbX9ZEyFkWPsRz7Bl3NuQUJohmwGSev/yhr7vhaGPlc4AfIrspIRa6cPTBuI1ItmrTDJ4d/S2hCsfe4+vQGnQ==", "license": "MIT", "dependencies": { "@stablelib/base64": "^1.0.0", diff --git a/src/code-samples/package.json b/src/code-samples/package.json index 12ca3add94..44072541e8 100644 --- a/src/code-samples/package.json +++ b/src/code-samples/package.json @@ -11,13 +11,13 @@ "license": "ISC", "dependencies": { "@google/genai": "^2.31.0", - "@langchain/anthropic": "^1.6.6", + "@langchain/anthropic": "^1.5.12", "@langchain/classic": "^1.0.0", "@langchain/core": "^1.3.7", "@langchain/daytona": "^0.2.3", "@langchain/google": "^0.2.7", "@langchain/google-genai": "^2.1.30", - "@langchain/langgraph": "^1.7.5", + "@langchain/langgraph": "^1.4.18", "@langchain/langgraph-checkpoint-postgres": "^1.0.1", "@langchain/mcp-adapters": "2.0.1", "@langchain/openai": "^1.8.3", @@ -30,12 +30,12 @@ "@modelcontextprotocol/sdk": "1.32.0", "@modelcontextprotocol/server": "2.4.0", "cheerio": "^1.0.0", - "deepagents": "^1.17.1", + "deepagents": "^1.16.2", "deepagents-acp": "^0.1.15", "dotenv": "^17.4.2", "hono": "^4.12.28", - "langchain": "^1.6.8", - "langsmith": "^0.14.0", + "langchain": "^1.5.18", + "langsmith": "^0.11.0", "managed-deepagents": "^0.9.5", "openai": "^7.45.1", "openevals": "^0.2.3", diff --git a/src/oss/deepagents/subagents.mdx b/src/oss/deepagents/subagents.mdx index 28a189f9ab..f4a0721852 100644 --- a/src/oss/deepagents/subagents.mdx +++ b/src/oss/deepagents/subagents.mdx @@ -7,7 +7,6 @@ import SubagentBasicPy from '/snippets/code-samples/subagent-basic-py.mdx'; import SubagentBasicJs from '/snippets/code-samples/subagent-basic-js.mdx'; import SubagentStreamProgressPy from '/snippets/code-samples/subagent-stream-progress-py.mdx'; import SubagentStreamProgressJs from '/snippets/code-samples/subagent-stream-progress-js.mdx'; -import SubagentsCheckpointNsJs from '/snippets/code-samples/subagents-checkpoint-ns-js.mdx'; import SubagentsCompiledSubagentPy from '/snippets/code-samples/subagents-compiled-subagent-py.mdx'; import SubagentsCompiledSubagentJs from '/snippets/code-samples/subagents-compiled-subagent-js.mdx'; import ForkedSubagentsBasicPy from '/snippets/code-samples/forked-subagents-basic-py.mdx'; @@ -515,24 +514,6 @@ The simplest pattern is to iterate `stream.subagents` to track each delegated ta ::: -:::js -### Checkpoint namespace on task result - -When a subagent finishes, the `ToolMessage` returned to the parent carries the checkpoint namespace in `artifact.checkpoint_ns`. A client can load the finished subagent's checkpoint history from that namespace, without scanning the full thread. - -The model never sees `artifact`; it is metadata for client-side consumption only. - -Checkpointing must be active for the artifact to be set. Pass a checkpointer when you create the agent, and a `thread_id` when you run it: - - - -When checkpointing is not configured or the subagent did not save any checkpoints, `artifact` is not set on the `ToolMessage`. - - - The `checkpoint_ns` artifact on task results requires `deepagents>=1.16.5`. - -::: - ### LangSmith tracing As your deep agent runs, all runs executed by a subagent or the coordinator will have the agent name in their metadata under the `lc_agent_name` key—for example, `{'lc_agent_name': 'research-agent'}`. This lets you identify and filter runs by subagent in LangSmith. diff --git a/src/snippets/code-samples/subagents-checkpoint-ns-js.mdx b/src/snippets/code-samples/subagents-checkpoint-ns-js.mdx deleted file mode 100644 index c55e4df89c..0000000000 --- a/src/snippets/code-samples/subagents-checkpoint-ns-js.mdx +++ /dev/null @@ -1,365 +0,0 @@ - - ```ts Google - import { ToolMessage } from "langchain"; - import { MemorySaver } from "@langchain/langgraph"; - import { createDeepAgent } from "deepagents"; - - const checkpointer = new MemorySaver(); - const agent = await createDeepAgent({ - model: "google:gemini-4-hydrogen", - checkpointer, - name: "main-agent", - systemPrompt: - "You are a project coordinator with no research knowledge. " + - "For every user request, you must call the task() tool with " + - "subagent_type set to research-agent. Never answer research " + - "questions yourself.", - subagents: [ - { - name: "research-agent", - description: - "Delegate research to this subagent. Give one topic at a time.", - systemPrompt: "You are a great researcher. Return a brief summary.", - }, - ], - }); - - const threadId = "example-thread"; - const result = await agent.invoke( - { - messages: [ - { - role: "user", - content: "Research one recent advance in quantum computing.", - }, - ], - }, - { configurable: { thread_id: threadId } }, - ); - - const taskMessage = result.messages.find( - (msg) => ToolMessage.isInstance(msg) && msg.name === "task", - ); - const checkpointNs = taskMessage?.artifact?.checkpoint_ns; - - if (checkpointNs) { - for await (const snapshot of agent.getStateHistory({ - configurable: { thread_id: threadId, checkpoint_ns: checkpointNs }, - })) { - console.log(snapshot.values); - } - } - ``` - - ```ts OpenAI - import { ToolMessage } from "langchain"; - import { MemorySaver } from "@langchain/langgraph"; - import { createDeepAgent } from "deepagents"; - - const checkpointer = new MemorySaver(); - const agent = await createDeepAgent({ - model: "openai:gpt-6.1-sol", - checkpointer, - name: "main-agent", - systemPrompt: - "You are a project coordinator with no research knowledge. " + - "For every user request, you must call the task() tool with " + - "subagent_type set to research-agent. Never answer research " + - "questions yourself.", - subagents: [ - { - name: "research-agent", - description: - "Delegate research to this subagent. Give one topic at a time.", - systemPrompt: "You are a great researcher. Return a brief summary.", - }, - ], - }); - - const threadId = "example-thread"; - const result = await agent.invoke( - { - messages: [ - { - role: "user", - content: "Research one recent advance in quantum computing.", - }, - ], - }, - { configurable: { thread_id: threadId } }, - ); - - const taskMessage = result.messages.find( - (msg) => ToolMessage.isInstance(msg) && msg.name === "task", - ); - const checkpointNs = taskMessage?.artifact?.checkpoint_ns; - - if (checkpointNs) { - for await (const snapshot of agent.getStateHistory({ - configurable: { thread_id: threadId, checkpoint_ns: checkpointNs }, - })) { - console.log(snapshot.values); - } - } - ``` - - ```ts Anthropic - import { ToolMessage } from "langchain"; - import { MemorySaver } from "@langchain/langgraph"; - import { createDeepAgent } from "deepagents"; - - const checkpointer = new MemorySaver(); - const agent = await createDeepAgent({ - model: "anthropic:claude-sonnet-5", - checkpointer, - name: "main-agent", - systemPrompt: - "You are a project coordinator with no research knowledge. " + - "For every user request, you must call the task() tool with " + - "subagent_type set to research-agent. Never answer research " + - "questions yourself.", - subagents: [ - { - name: "research-agent", - description: - "Delegate research to this subagent. Give one topic at a time.", - systemPrompt: "You are a great researcher. Return a brief summary.", - }, - ], - }); - - const threadId = "example-thread"; - const result = await agent.invoke( - { - messages: [ - { - role: "user", - content: "Research one recent advance in quantum computing.", - }, - ], - }, - { configurable: { thread_id: threadId } }, - ); - - const taskMessage = result.messages.find( - (msg) => ToolMessage.isInstance(msg) && msg.name === "task", - ); - const checkpointNs = taskMessage?.artifact?.checkpoint_ns; - - if (checkpointNs) { - for await (const snapshot of agent.getStateHistory({ - configurable: { thread_id: threadId, checkpoint_ns: checkpointNs }, - })) { - console.log(snapshot.values); - } - } - ``` - - ```ts OpenRouter - import { ToolMessage } from "langchain"; - import { MemorySaver } from "@langchain/langgraph"; - import { createDeepAgent } from "deepagents"; - - const checkpointer = new MemorySaver(); - const agent = await createDeepAgent({ - model: "openrouter:z-ai/glm-5.2", - checkpointer, - name: "main-agent", - systemPrompt: - "You are a project coordinator with no research knowledge. " + - "For every user request, you must call the task() tool with " + - "subagent_type set to research-agent. Never answer research " + - "questions yourself.", - subagents: [ - { - name: "research-agent", - description: - "Delegate research to this subagent. Give one topic at a time.", - systemPrompt: "You are a great researcher. Return a brief summary.", - }, - ], - }); - - const threadId = "example-thread"; - const result = await agent.invoke( - { - messages: [ - { - role: "user", - content: "Research one recent advance in quantum computing.", - }, - ], - }, - { configurable: { thread_id: threadId } }, - ); - - const taskMessage = result.messages.find( - (msg) => ToolMessage.isInstance(msg) && msg.name === "task", - ); - const checkpointNs = taskMessage?.artifact?.checkpoint_ns; - - if (checkpointNs) { - for await (const snapshot of agent.getStateHistory({ - configurable: { thread_id: threadId, checkpoint_ns: checkpointNs }, - })) { - console.log(snapshot.values); - } - } - ``` - - ```ts Fireworks - import { ToolMessage } from "langchain"; - import { MemorySaver } from "@langchain/langgraph"; - import { createDeepAgent } from "deepagents"; - - const checkpointer = new MemorySaver(); - const agent = await createDeepAgent({ - model: "fireworks:accounts/fireworks/models/glm-5p2", - checkpointer, - name: "main-agent", - systemPrompt: - "You are a project coordinator with no research knowledge. " + - "For every user request, you must call the task() tool with " + - "subagent_type set to research-agent. Never answer research " + - "questions yourself.", - subagents: [ - { - name: "research-agent", - description: - "Delegate research to this subagent. Give one topic at a time.", - systemPrompt: "You are a great researcher. Return a brief summary.", - }, - ], - }); - - const threadId = "example-thread"; - const result = await agent.invoke( - { - messages: [ - { - role: "user", - content: "Research one recent advance in quantum computing.", - }, - ], - }, - { configurable: { thread_id: threadId } }, - ); - - const taskMessage = result.messages.find( - (msg) => ToolMessage.isInstance(msg) && msg.name === "task", - ); - const checkpointNs = taskMessage?.artifact?.checkpoint_ns; - - if (checkpointNs) { - for await (const snapshot of agent.getStateHistory({ - configurable: { thread_id: threadId, checkpoint_ns: checkpointNs }, - })) { - console.log(snapshot.values); - } - } - ``` - - ```ts Baseten - import { ToolMessage } from "langchain"; - import { MemorySaver } from "@langchain/langgraph"; - import { createDeepAgent } from "deepagents"; - - const checkpointer = new MemorySaver(); - const agent = await createDeepAgent({ - model: "baseten:zai-org/GLM-5.2", - checkpointer, - name: "main-agent", - systemPrompt: - "You are a project coordinator with no research knowledge. " + - "For every user request, you must call the task() tool with " + - "subagent_type set to research-agent. Never answer research " + - "questions yourself.", - subagents: [ - { - name: "research-agent", - description: - "Delegate research to this subagent. Give one topic at a time.", - systemPrompt: "You are a great researcher. Return a brief summary.", - }, - ], - }); - - const threadId = "example-thread"; - const result = await agent.invoke( - { - messages: [ - { - role: "user", - content: "Research one recent advance in quantum computing.", - }, - ], - }, - { configurable: { thread_id: threadId } }, - ); - - const taskMessage = result.messages.find( - (msg) => ToolMessage.isInstance(msg) && msg.name === "task", - ); - const checkpointNs = taskMessage?.artifact?.checkpoint_ns; - - if (checkpointNs) { - for await (const snapshot of agent.getStateHistory({ - configurable: { thread_id: threadId, checkpoint_ns: checkpointNs }, - })) { - console.log(snapshot.values); - } - } - ``` - - ```ts Ollama - import { ToolMessage } from "langchain"; - import { MemorySaver } from "@langchain/langgraph"; - import { createDeepAgent } from "deepagents"; - - const checkpointer = new MemorySaver(); - const agent = await createDeepAgent({ - model: "ollama:north-mini-code-1.0", - checkpointer, - name: "main-agent", - systemPrompt: - "You are a project coordinator with no research knowledge. " + - "For every user request, you must call the task() tool with " + - "subagent_type set to research-agent. Never answer research " + - "questions yourself.", - subagents: [ - { - name: "research-agent", - description: - "Delegate research to this subagent. Give one topic at a time.", - systemPrompt: "You are a great researcher. Return a brief summary.", - }, - ], - }); - - const threadId = "example-thread"; - const result = await agent.invoke( - { - messages: [ - { - role: "user", - content: "Research one recent advance in quantum computing.", - }, - ], - }, - { configurable: { thread_id: threadId } }, - ); - - const taskMessage = result.messages.find( - (msg) => ToolMessage.isInstance(msg) && msg.name === "task", - ); - const checkpointNs = taskMessage?.artifact?.checkpoint_ns; - - if (checkpointNs) { - for await (const snapshot of agent.getStateHistory({ - configurable: { thread_id: threadId, checkpoint_ns: checkpointNs }, - })) { - console.log(snapshot.values); - } - } - ``` - From 5131f4cea2c01701e90ef71f3c8773de90d36d74 Mon Sep 17 00:00:00 2001 From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> Date: Thu, 26 Nov 2026 15:08:14 +0100 Subject: [PATCH 5/6] shorten --- src/oss/deepagents/subagents.mdx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/oss/deepagents/subagents.mdx b/src/oss/deepagents/subagents.mdx index f4a0721852..6affe20f6c 100644 --- a/src/oss/deepagents/subagents.mdx +++ b/src/oss/deepagents/subagents.mdx @@ -514,6 +514,22 @@ The simplest pattern is to iterate `stream.subagents` to track each delegated ta ::: +### Checkpoint namespace on task result + +When a subagent finishes with checkpointing active, the `task` tool's `ToolMessage` carries `artifact.checkpoint_ns`, the namespace the subagent saved under. Clients can load that subagent's history from the namespace instead of scanning the thread. The model never sees `artifact`. + +:::python + + The `checkpoint_ns` artifact on task results requires `deepagents>=0.7.36`. + +::: + +:::js + + The `checkpoint_ns` artifact on task results requires `deepagents>=1.16.5`. + +::: + ### LangSmith tracing As your deep agent runs, all runs executed by a subagent or the coordinator will have the agent name in their metadata under the `lc_agent_name` key—for example, `{'lc_agent_name': 'research-agent'}`. This lets you identify and filter runs by subagent in LangSmith. From b000cbd6cf9daa4fdbc7d1c6c0ed88a13d861898 Mon Sep 17 00:00:00 2001 From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> Date: Thu, 26 Nov 2026 15:18:18 +0100 Subject: [PATCH 6/6] Apply suggestion from @npentrel --- src/oss/deepagents/subagents.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/oss/deepagents/subagents.mdx b/src/oss/deepagents/subagents.mdx index 6affe20f6c..c228baa604 100644 --- a/src/oss/deepagents/subagents.mdx +++ b/src/oss/deepagents/subagents.mdx @@ -516,7 +516,7 @@ The simplest pattern is to iterate `stream.subagents` to track each delegated ta ### Checkpoint namespace on task result -When a subagent finishes with checkpointing active, the `task` tool's `ToolMessage` carries `artifact.checkpoint_ns`, the namespace the subagent saved under. Clients can load that subagent's history from the namespace instead of scanning the thread. The model never sees `artifact`. +When a subagent finishes with checkpointing active, the `task` tool's `ToolMessage` carries `artifact.checkpoint_ns`, the namespace the subagent saved under. Clients can load that subagent's history from the namespace instead of scanning the thread. :::python