Use zod schema defaults when extracting channels #380

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

Originally created by @hntrl on GitHub (Nov 26, 2025).

Privileged issue

  • I am a LangGraph.js maintainer, or was asked directly by a LangGraph.js maintainer to create an issue here.

Issue Content

Currently, in order to set a default for a state key when using zod schemas, I have to do something like this:

import * as z from "zod";
import { registry } from "@langchain/langgraph/zod";

const schema = z.object({
  foo: z.string().register(registry, {
    default: () => "bar"
  })
});

const graph = new StateGraph(schema);

But I should be able to set defaults inside of a zod schema using the native method:

import * as z from "zod";
import { StateGraph } from "@langchain/langgraph";

const schema = z.object({
  foo: z.string().default("bar")
});

const graph = new StateGraph(schema);
Originally created by @hntrl on GitHub (Nov 26, 2025). ### Privileged issue - [x] I am a LangGraph.js maintainer, or was asked directly by a LangGraph.js maintainer to create an issue here. ### Issue Content Currently, in order to set a default for a state key when using zod schemas, I have to do something like this: ```ts import * as z from "zod"; import { registry } from "@langchain/langgraph/zod"; const schema = z.object({ foo: z.string().register(registry, { default: () => "bar" }) }); const graph = new StateGraph(schema); ``` But I should be able to set defaults inside of a zod schema using the native method: ```ts import * as z from "zod"; import { StateGraph } from "@langchain/langgraph"; const schema = z.object({ foo: z.string().default("bar") }); const graph = new StateGraph(schema); ```
yindo closed this issue 2026-02-15 18:16:21 -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#380