langchain.js
    Preparing search index...

    Variable MessagesZodStateConst

    MessagesZodState: ZodObject<
        {
            messages: ReducedZodChannel<
                ZodType<
                    BaseMessage<MessageStructure, MessageType>[],
                    ZodTypeDef,
                    BaseMessage<MessageStructure, MessageType>[],
                >,
                InteropZodType<Messages>,
            >;
        },
        "strip",
        ZodTypeAny,
        { messages: BaseMessage<MessageStructure, MessageType>[] },
        { messages: BaseMessage<MessageStructure, MessageType>[] },
    > = ...

    Prebuilt state object that uses Zod to combine returned messages. This utility is synonymous with the MessagesAnnotation annotation, but uses Zod as the way to express messages state.

    You can use import and use this prebuilt schema like this:

    import { MessagesZodState, StateGraph } from "@langchain/langgraph";

    const graph = new StateGraph(MessagesZodState)
    .addNode(...)
    ...

    Which is equivalent to initializing the schema object manually like this:

    import { z } from "zod";
    import type { BaseMessage, BaseMessageLike } from "@langchain/core/messages";
    import { StateGraph, messagesStateReducer } from "@langchain/langgraph";
    import "@langchain/langgraph/zod";

    const AgentState = z.object({
    messages: z
    .custom<BaseMessage[]>()
    .default(() => [])
    .langgraph.reducer(
    messagesStateReducer,
    z.custom<BaseMessageLike | BaseMessageLike[]>()
    ),
    });
    const graph = new StateGraph(AgentState)
    .addNode(...)
    ...