function validate() cannot be used or it's not achieved yet? #147

Closed
opened 2026-02-15 17:16:17 -05:00 by yindo · 1 comment
Owner

Originally created by @oneWalker on GitHub (Dec 22, 2024).

It can be run successfully.

//here is my demo code

let workflow = new StateGraph(MessagesAnnotation);
// Add nodes
Nodes.forEach((node) => {
    const nodeFunction = getNodeFunction(node);
    if (nodeFunction) {
        workflow.addNode(node.Name, nodeFunction);
    }
});

// Add edges
Edges.forEach((edge) => {
    if (edge.SourceType === 'start') {
        workflow.addEdge(START, edge.Target as any);
    } else if (edge.TargetType === 'end') {
        workflow.addEdge(edge.Source as any, END);
    } else {
        workflow.addEdge(edge.Source as any, edge.Target as any);
    }
});

let checkpointer = new MemorySaver();
//print checkpointer
console.log('checkpointer', checkpointer);

//problematic place:
const isValid = workflow.validate();
console.log('isValid', isValid); //undefined

const graph = workflow.compile({ checkpointer });
console.log('graph', graph);

//problematic place:
const isValid = workflow.validate();
console.log('isValid', isValid);  // undefined

Originally created by @oneWalker on GitHub (Dec 22, 2024). It can be run successfully. ```ts //here is my demo code let workflow = new StateGraph(MessagesAnnotation); // Add nodes Nodes.forEach((node) => { const nodeFunction = getNodeFunction(node); if (nodeFunction) { workflow.addNode(node.Name, nodeFunction); } }); // Add edges Edges.forEach((edge) => { if (edge.SourceType === 'start') { workflow.addEdge(START, edge.Target as any); } else if (edge.TargetType === 'end') { workflow.addEdge(edge.Source as any, END); } else { workflow.addEdge(edge.Source as any, edge.Target as any); } }); let checkpointer = new MemorySaver(); //print checkpointer console.log('checkpointer', checkpointer); //problematic place: const isValid = workflow.validate(); console.log('isValid', isValid); //undefined const graph = workflow.compile({ checkpointer }); console.log('graph', graph); //problematic place: const isValid = workflow.validate(); console.log('isValid', isValid); // undefined ```
yindo closed this issue 2026-02-15 17:16:17 -05:00
Author
Owner

@oneWalker commented on GitHub (Dec 22, 2024):

solved with workflow.compiled;

@oneWalker commented on GitHub (Dec 22, 2024): solved with `workflow.compiled`;
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#147