[PR #160] [MERGED] fix: missing files in skillsMiddleware schema #168

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/160
Author: @maahir30
Created: 1/31/2026
Status: Merged
Merged: 2/3/2026
Merged by: @christian-bromann

Base: mainHead: fix-skills-middleware


📝 Commits (8)

📊 Changes

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

View changed files

.changeset/fix-skills-middleware.md (+9 -0)
📝 libs/deepagents/src/middleware/fs.ts (+1 -1)
📝 libs/deepagents/src/middleware/skills.test.ts (+265 -0)
📝 libs/deepagents/src/middleware/skills.ts (+14 -1)

📄 Description

Summary

  • Add files field to SkillsStateSchema so StateBackend can access files
  • Export FileDataSchema from fs.ts for reuse across middleware

Problem

SkillsMiddleware fails to load skill files when using StateBackend because SkillsStateSchema doesn't declare the files field. LangGraph filters state passed to middleware based on their declared schema, so beforeAgent receives state without files, causing StateBackend operations to fail.

Solution

Add the files field to SkillsStateSchema using the same ReducedValue pattern as FilesystemStateSchema:

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/160 **Author:** [@maahir30](https://github.com/maahir30) **Created:** 1/31/2026 **Status:** ✅ Merged **Merged:** 2/3/2026 **Merged by:** [@christian-bromann](https://github.com/christian-bromann) **Base:** `main` ← **Head:** `fix-skills-middleware` --- ### 📝 Commits (8) - [`e56596c`](https://github.com/langchain-ai/deepagentsjs/commit/e56596c60d87ec04eaa7df8d9f8e6c2fe45a94cd) fix missing files in skillsMiddleware - [`8c276dd`](https://github.com/langchain-ai/deepagentsjs/commit/8c276dd677d34f2f55cbcde167ac41013ef3a334) Update tests - [`40c7bd4`](https://github.com/langchain-ai/deepagentsjs/commit/40c7bd4a5e4d7ef3e02d295c34b0432b24a04fea) Add integration tests + fixes - [`3e489c3`](https://github.com/langchain-ai/deepagentsjs/commit/3e489c332c00dbceea194e7851d8601b323fdb0a) Restore skills.test.ts from main - [`c695945`](https://github.com/langchain-ai/deepagentsjs/commit/c695945d6fc58893292c30b3eb82de4401305088) Update tests to unit from integration - [`c45b112`](https://github.com/langchain-ai/deepagentsjs/commit/c45b1128ce8d97432ae7ece316f5238679e02ce9) Update unit tests - [`4323008`](https://github.com/langchain-ai/deepagentsjs/commit/4323008846db3b36fde074a04bef406ffef0cc77) fix test - [`407c28f`](https://github.com/langchain-ai/deepagentsjs/commit/407c28f18055b240c8e6fe882527a97ac931c06a) changeset ### 📊 Changes **4 files changed** (+289 additions, -2 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/fix-skills-middleware.md` (+9 -0) 📝 `libs/deepagents/src/middleware/fs.ts` (+1 -1) 📝 `libs/deepagents/src/middleware/skills.test.ts` (+265 -0) 📝 `libs/deepagents/src/middleware/skills.ts` (+14 -1) </details> ### 📄 Description ## Summary - Add `files` field to `SkillsStateSchema` so `StateBackend` can access files - Export `FileDataSchema` from `fs.ts` for reuse across middleware ## Problem `SkillsMiddleware` fails to load skill files when using `StateBackend` because `SkillsStateSchema` doesn't declare the `files` field. LangGraph filters state passed to middleware based on their declared schema, so `beforeAgent` receives state without `files`, causing `StateBackend` operations to fail. ## Solution Add the `files` field to `SkillsStateSchema` using the same `ReducedValue` pattern as `FilesystemStateSchema`: ```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#168