deepagents 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +19 -13
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -405,6 +405,16 @@ function fileDataReducer(left, right) {
405
405
  return result;
406
406
  }
407
407
  /**
408
+ * Shared filesystem state schema.
409
+ * Defined at module level to ensure the same object identity is used across all agents,
410
+ * preventing "Channel already exists with different type" errors when multiple agents
411
+ * use createFilesystemMiddleware.
412
+ */
413
+ const FilesystemStateSchema = z.object({ files: withLangGraph(z.record(z.string(), FileDataSchema).default({}), { reducer: {
414
+ fn: fileDataReducer,
415
+ schema: z.record(z.string(), FileDataSchema.nullable())
416
+ } }) });
417
+ /**
408
418
  * Resolve backend from factory or instance.
409
419
  *
410
420
  * @param backend - Backend instance or factory function
@@ -607,21 +617,17 @@ function createGrepTool(backend, options) {
607
617
  function createFilesystemMiddleware(options = {}) {
608
618
  const { backend = (stateAndStore) => new StateBackend(stateAndStore), systemPrompt: customSystemPrompt = null, customToolDescriptions = null, toolTokenLimitBeforeEvict = 2e4 } = options;
609
619
  const systemPrompt = customSystemPrompt || FILESYSTEM_SYSTEM_PROMPT;
610
- const tools = [
611
- createLsTool(backend, { customDescription: customToolDescriptions?.ls }),
612
- createReadFileTool(backend, { customDescription: customToolDescriptions?.read_file }),
613
- createWriteFileTool(backend, { customDescription: customToolDescriptions?.write_file }),
614
- createEditFileTool(backend, { customDescription: customToolDescriptions?.edit_file }),
615
- createGlobTool(backend, { customDescription: customToolDescriptions?.glob }),
616
- createGrepTool(backend, { customDescription: customToolDescriptions?.grep })
617
- ];
618
620
  return createMiddleware({
619
621
  name: "FilesystemMiddleware",
620
- stateSchema: z.object({ files: withLangGraph(z.record(z.string(), FileDataSchema).default({}), { reducer: {
621
- fn: fileDataReducer,
622
- schema: z.record(z.string(), FileDataSchema.nullable())
623
- } }) }),
624
- tools,
622
+ stateSchema: FilesystemStateSchema,
623
+ tools: [
624
+ createLsTool(backend, { customDescription: customToolDescriptions?.ls }),
625
+ createReadFileTool(backend, { customDescription: customToolDescriptions?.read_file }),
626
+ createWriteFileTool(backend, { customDescription: customToolDescriptions?.write_file }),
627
+ createEditFileTool(backend, { customDescription: customToolDescriptions?.edit_file }),
628
+ createGlobTool(backend, { customDescription: customToolDescriptions?.glob }),
629
+ createGrepTool(backend, { customDescription: customToolDescriptions?.grep })
630
+ ],
625
631
  wrapModelCall: systemPrompt ? async (request, handler) => {
626
632
  const currentSystemPrompt = request.systemPrompt || "";
627
633
  const newSystemPrompt = currentSystemPrompt ? `${currentSystemPrompt}\n\n${systemPrompt}` : systemPrompt;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepagents",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Deep Agents - a library for building controllable AI agents with LangGraph",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",