Skip to content

Use zod schema defaults when extracting channels #1795

@hntrl

Description

@hntrl

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions