[PR #569] [MERGED] feat(deepagents): Add support for stateSchema to createDeepAgent() #567

Closed
opened 2026-06-05 17:23:46 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagentsjs/pull/569
Author: @aolsenjazz
Created: 6/1/2026
Status: Merged
Merged: 6/2/2026
Merged by: @aolsenjazz

Base: mainHead: alex/deepagents-stateschema


📝 Commits (9)

  • 2db9f6a Add stateSchema type arg to createDeepAgent, pipe to createAgent and return typedef
  • de07eed Widen DeepAgentTypeConfig TState, add TStateSchema type to CreateDeepAgentParams
  • faaf84a Add state schema propagation test
  • 8eb317b Add type propgation tests
  • f26273d Narrow CreateDeepAgentParams TStateSchema typedef
  • 053d438 Narrow createDeepAgent TStateSchema typedef
  • aadbb45 Update test re. accepted stateSchema types
  • 2d5d197 Update CreateDeepAgentParams docstring
  • 30924d3 Refactor agent.test-d.ts for clarity

📊 Changes

4 files changed (+108 additions, -12 deletions)

View changed files

📝 libs/deepagents/src/agent.test-d.ts (+38 -0)
📝 libs/deepagents/src/agent.test.ts (+17 -1)
📝 libs/deepagents/src/agent.ts (+14 -7)
📝 libs/deepagents/src/types.ts (+39 -4)

📄 Description

Summary

Adds support for stateSchema to createDeepAgent() as well as accompanying tests. Example:

const stateSchema = new StateSchema({
  foo: z.string().default("foo"),
});
const agent = createDeepAgent({ model, stateSchema });
// agent.graph.channels includes attribute foo

Callouts

Opted against compile/runtime check for stateSchema keys
There is a strong argument here to add a compile-time or runtime check to ensure uniqueness of stateSchema keys to guard against the first-writer-wins behavior of channel merging. There is already a runtime tool name check. However the topic of how channel merging is handled, I think, deserves a fast follow to ensure that consumers of this API are properly educated (rather than just throwing in this key concept into a single docstring). Action item here is that I would love to treat this as a fast follow, and chat about if/how we're educating consumers about this concept.

Protocol re. changesets
Happy to run changeset to bump minor version. What is the protocol here?


🔄 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/569 **Author:** [@aolsenjazz](https://github.com/aolsenjazz) **Created:** 6/1/2026 **Status:** ✅ Merged **Merged:** 6/2/2026 **Merged by:** [@aolsenjazz](https://github.com/aolsenjazz) **Base:** `main` ← **Head:** `alex/deepagents-stateschema` --- ### 📝 Commits (9) - [`2db9f6a`](https://github.com/langchain-ai/deepagentsjs/commit/2db9f6a8df2e5b49c4d253781baced9858776540) Add stateSchema type arg to createDeepAgent, pipe to createAgent and return typedef - [`de07eed`](https://github.com/langchain-ai/deepagentsjs/commit/de07eed839060f6f2fc19b9855154c31593679cf) Widen DeepAgentTypeConfig TState, add TStateSchema type to CreateDeepAgentParams - [`faaf84a`](https://github.com/langchain-ai/deepagentsjs/commit/faaf84a1889d05eca908210152e24111acf42088) Add state schema propagation test - [`8eb317b`](https://github.com/langchain-ai/deepagentsjs/commit/8eb317b9478f28eb7ac65822458095c78fd51699) Add type propgation tests - [`f26273d`](https://github.com/langchain-ai/deepagentsjs/commit/f26273d8c3dd9a4dc1e16e21bed0466e2f94df78) Narrow CreateDeepAgentParams TStateSchema typedef - [`053d438`](https://github.com/langchain-ai/deepagentsjs/commit/053d4382815239184d23be650866122359cd16ce) Narrow createDeepAgent TStateSchema typedef - [`aadbb45`](https://github.com/langchain-ai/deepagentsjs/commit/aadbb451ca118e6fad42b94ada7b47764a2e2532) Update test re. accepted stateSchema types - [`2d5d197`](https://github.com/langchain-ai/deepagentsjs/commit/2d5d1977d6f313a95f6552f2f360a2e091048e20) Update CreateDeepAgentParams docstring - [`30924d3`](https://github.com/langchain-ai/deepagentsjs/commit/30924d313aadb9ab0817553e7c38f737c023eb0d) Refactor agent.test-d.ts for clarity ### 📊 Changes **4 files changed** (+108 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `libs/deepagents/src/agent.test-d.ts` (+38 -0) 📝 `libs/deepagents/src/agent.test.ts` (+17 -1) 📝 `libs/deepagents/src/agent.ts` (+14 -7) 📝 `libs/deepagents/src/types.ts` (+39 -4) </details> ### 📄 Description ## Summary Adds support for `stateSchema` to `createDeepAgent()` as well as accompanying tests. Example: ``` const stateSchema = new StateSchema({ foo: z.string().default("foo"), }); const agent = createDeepAgent({ model, stateSchema }); // agent.graph.channels includes attribute foo ``` ### Callouts **Opted against compile/runtime check for stateSchema keys** There is a strong argument here to add a compile-time or runtime check to ensure uniqueness of `stateSchema` keys to guard against the first-writer-wins behavior of channel merging. [There is already a runtime tool name check](https://github.com/langchain-ai/deepagentsjs/blob/c524561ad0c4b13075b0d0999236f09bf5f6cb89/libs/deepagents/src/agent.ts#L185). However the topic of how channel merging is handled, I think, deserves a fast follow to ensure that consumers of this API are properly educated (rather than just throwing in this key concept into a single docstring). **Action item here is that I would love to treat this as a fast follow, and chat about if/how we're educating consumers about this concept.** **Protocol re. changesets** Happy to run changeset to bump minor version. What is the protocol here? --- <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-06-05 17:23:46 -04:00
yindo closed this issue 2026-06-05 17:23:46 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagentsjs#567