[PR #159] [MERGED] fix: missing files/memoryContents in memory middleware #167

Closed
opened 2026-02-16 06:17:20 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagentsjs/pull/159
Author: @maahir30
Created: 1/31/2026
Status: Merged
Merged: 2/2/2026
Merged by: @christian-bromann

Base: mainHead: update-memory-schema


📝 Commits (10+)

  • 5175b4e Update memory state schmea
  • 27d3103 Update tests
  • 88bcc1d Merge branch 'main' into update-memory-schema
  • f8be1ab Update testing
  • ba42e60 changeset
  • 66ad379 Update libs/deepagents/src/middleware/memory.test.ts
  • 03d44b2 Update libs/deepagents/src/middleware/memory.test.ts
  • 6258b35 Update libs/deepagents/src/middleware/memory.test.ts
  • ba3f5b4 Update libs/deepagents/src/middleware/memory.test.ts
  • 308c84c Update libs/deepagents/src/middleware/memory.test.ts

📊 Changes

4 files changed (+252 additions, -2 deletions)

View changed files

.changeset/memory-statebackend-tests.md (+9 -0)
📝 libs/deepagents/src/middleware/fs.ts (+1 -1)
📝 libs/deepagents/src/middleware/memory.test.ts (+232 -0)
📝 libs/deepagents/src/middleware/memory.ts (+10 -1)

📄 Description

Summary

  • Add files field to MemoryStateSchema so LangGraph passes file state to the memory middleware
  • Export FileDataSchema and fileDataReducer from fs.ts for reuse

Problem

When using MemoryMiddleware with StateBackend, memory files (like AGENTS.md) fail to load with file_not_found errors. This happens because LangGraph filters state based on the middleware's declared stateSchema, and MemoryStateSchema didn't include files.

The beforeAgent hook receives state without the files property, so StateBackend.getFiles() returns undefined.

Solution

Include the same files field definition in MemoryStateSchema that FilesystemStateSchema uses:

files: new ReducedValue(
  z.record(z.string(), FileDataSchema).default(() => ({})),
  {
    inputSchema: z.record(z.string(), FileDataSchema.nullable()).optional(),
    reducer: fileDataReducer,
  },
),

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/deepagentsjs/pull/159 **Author:** [@maahir30](https://github.com/maahir30) **Created:** 1/31/2026 **Status:** ✅ Merged **Merged:** 2/2/2026 **Merged by:** [@christian-bromann](https://github.com/christian-bromann) **Base:** `main` ← **Head:** `update-memory-schema` --- ### 📝 Commits (10+) - [`5175b4e`](https://github.com/langchain-ai/deepagentsjs/commit/5175b4e6e49975fe334dbfb9591fc84d1a4c2955) Update memory state schmea - [`27d3103`](https://github.com/langchain-ai/deepagentsjs/commit/27d31031667d66ba77c2f1b9f1243156eadc7ea1) Update tests - [`88bcc1d`](https://github.com/langchain-ai/deepagentsjs/commit/88bcc1db774b12929f696e65d7c58ddeb5ae7b87) Merge branch 'main' into update-memory-schema - [`f8be1ab`](https://github.com/langchain-ai/deepagentsjs/commit/f8be1ab6e4c2fa84e402f9621782be3d92d9a54c) Update testing - [`ba42e60`](https://github.com/langchain-ai/deepagentsjs/commit/ba42e6072a3c57f59e8509d293f3258dadd7b97b) changeset - [`66ad379`](https://github.com/langchain-ai/deepagentsjs/commit/66ad379c19350f1f9e2d941396cf2a7d4e297af7) Update libs/deepagents/src/middleware/memory.test.ts - [`03d44b2`](https://github.com/langchain-ai/deepagentsjs/commit/03d44b22a1f33df4b471c758cee3dc61b99558a0) Update libs/deepagents/src/middleware/memory.test.ts - [`6258b35`](https://github.com/langchain-ai/deepagentsjs/commit/6258b354b7d55648ccdb73cdafc1ef64d8b3a06c) Update libs/deepagents/src/middleware/memory.test.ts - [`ba3f5b4`](https://github.com/langchain-ai/deepagentsjs/commit/ba3f5b4de47fd122d1a41212aafe059d99d8d2c0) Update libs/deepagents/src/middleware/memory.test.ts - [`308c84c`](https://github.com/langchain-ai/deepagentsjs/commit/308c84c2ff5e88b2926f7b9c07cbee9cd7b5414d) Update libs/deepagents/src/middleware/memory.test.ts ### 📊 Changes **4 files changed** (+252 additions, -2 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/memory-statebackend-tests.md` (+9 -0) 📝 `libs/deepagents/src/middleware/fs.ts` (+1 -1) 📝 `libs/deepagents/src/middleware/memory.test.ts` (+232 -0) 📝 `libs/deepagents/src/middleware/memory.ts` (+10 -1) </details> ### 📄 Description ## Summary - Add `files` field to `MemoryStateSchema` so LangGraph passes file state to the memory middleware - Export `FileDataSchema` and `fileDataReducer` from `fs.ts` for reuse ## Problem When using `MemoryMiddleware` with `StateBackend`, memory files (like `AGENTS.md`) fail to load with `file_not_found` errors. This happens because LangGraph filters state based on the middleware's declared `stateSchema`, and `MemoryStateSchema` didn't include `files`. The `beforeAgent` hook receives state without the `files` property, so `StateBackend.getFiles()` returns `undefined`. ## Solution Include the same `files` field definition in `MemoryStateSchema` that `FilesystemStateSchema` uses: ```typescript files: new ReducedValue( z.record(z.string(), FileDataSchema).default(() => ({})), { inputSchema: z.record(z.string(), FileDataSchema.nullable()).optional(), reducer: fileDataReducer, }, ), ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 06:17:20 -05:00
yindo closed this issue 2026-02-16 06:17:20 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagentsjs#167