[PR #1510] [CLOSED] feat(langgraph): add support for standard schema in state definition #1506

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

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/langgraphjs/pull/1510
Author: @dqbd
Created: 8/8/2025
Status: Closed

Base: v1Head: dqbd/standard-schema


📝 Commits (1)

  • 64b0654 feat(langgraph): add support for standard schema in state definition

📊 Changes

4 files changed (+31 additions, -8 deletions)

View changed files

📝 libs/langgraph/package.json (+1 -0)
📝 libs/langgraph/src/graph/annotation.ts (+15 -1)
📝 libs/langgraph/src/graph/state.ts (+7 -7)
📝 yarn.lock (+8 -0)

📄 Description

Rethinking the current state of Zod in state definition, I think we can extend the Annotation function instead to accept Standard Schema objects.

Usage:

import { z } from "zod";
import { type } from "arktype";

const graph = new StateGraph(
  Annotation.Root({
    valid: z.boolean(),
    random: type("string"),
    complex: Annotation({
      state: z.string(),
      update: z.union([z.string(), z.array(z.string())]),
      reducer(state, update) {
        if (Array.isArray(update)) return [state, ...update].join(", ");
        return [state, update].join(", ");
      },
      default: () => "[default]",
    }),
  })
);

TODO:

  • Perform actual validation of inputs using the standard schema
  • Use runtime JSON schema generation for Zod
  • Add tests for Arktype, Valibot et all.
  • Consider renaming Annotation to channel
  • Think about getting rid of Annotation.Root

🔄 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/langgraphjs/pull/1510 **Author:** [@dqbd](https://github.com/dqbd) **Created:** 8/8/2025 **Status:** ❌ Closed **Base:** `v1` ← **Head:** `dqbd/standard-schema` --- ### 📝 Commits (1) - [`64b0654`](https://github.com/langchain-ai/langgraphjs/commit/64b0654a34187d353f207f37075e9ccfa3b1146f) feat(langgraph): add support for standard schema in state definition ### 📊 Changes **4 files changed** (+31 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `libs/langgraph/package.json` (+1 -0) 📝 `libs/langgraph/src/graph/annotation.ts` (+15 -1) 📝 `libs/langgraph/src/graph/state.ts` (+7 -7) 📝 `yarn.lock` (+8 -0) </details> ### 📄 Description Rethinking the current state of Zod in state definition, I think we can extend the Annotation function instead to accept Standard Schema objects. Usage: ```typescript import { z } from "zod"; import { type } from "arktype"; const graph = new StateGraph( Annotation.Root({ valid: z.boolean(), random: type("string"), complex: Annotation({ state: z.string(), update: z.union([z.string(), z.array(z.string())]), reducer(state, update) { if (Array.isArray(update)) return [state, ...update].join(", "); return [state, update].join(", "); }, default: () => "[default]", }), }) ); ``` TODO: - [ ] Perform actual validation of inputs using the standard schema - [ ] Use runtime JSON schema generation for Zod - [ ] Add tests for Arktype, Valibot et all. - [ ] Consider renaming `Annotation` to `channel` - [ ] Think about getting rid of `Annotation.Root` --- <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-15 20:16:01 -05:00
yindo closed this issue 2026-02-15 20:16:01 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#1506