Unkind error message while creating StateGraph #238

Closed
opened 2026-02-15 18:14:55 -05:00 by yindo · 6 comments
Owner

Originally created by @zerobell-lee on GitHub (Apr 27, 2025).

Stack

  • nextron(next.js + electron) + langgraph + langchain

Symptom

  • Cannot create StateGraph and it gives useless error message.
  • The error message is Error: Invalid StateGraph input.

Details

  • I'm trying migration to Langgraph from Langchian.
  • I made a StateGraph and called the function, but it failed.
  • Then I got error message Error: Invalid StateGraph input. . Not directing which value, and how it is wrong.
  • I don't think this is quite different from UNKNOWN ERROR : post issue report langgraph community
  • So please consider elaborating error messages. Thank you.

Code blocks

// some lines are skipped
export const createGhostGraph = () => {
    const initialState: GhostState = {
        input: { input: "", isSystemMessage: false },
        character_setting: {} as CharacterSetting,
        user_setting: {} as any,
        llmProperties: {
            llmService: "",
            modelName: "",
            apiKey: "",
            temperature: 0
        },
        executor: null,
        aiResponseParser: new AIResponseParser('openai'),
        invocation_result: null,
        invocation_retry_policy: { maximum_trial: 3 },
        llm_response: null,
        chat_history: new AkagakuChatHistory([], 100),
        update_payload: null,
        final_response: null,
        tools: []
    };

    const graph = new StateGraph<GhostState>(initialState as any)
    .addNode("input", InputNode)
    .addNode("agent", AgentNode)
    .addNode("update", UpdateNode)
    .addNode("response", ResponseNode)
    .addNode("retry", RetryNode)
    .addEdge(START, "input")
    .addEdge("input", "agent")
    .addEdge("agent", "response")
    .addEdge("response", "update")
    .addEdge("update", END)
    .addConditionalEdges("response", {
        condition: (state) => {
            console.log('state', state)
            const { invocation_result, invocation_retry_policy } = state;
            if (invocation_result?.success === true) {
                return 'ok';
            } else if (invocation_result?.success === false && invocation_result.error_type === 'parseError' && invocation_result?.trial_count < invocation_retry_policy?.maximum_trial) {
                return 'retry';
            } else {
                return 'end';
            }
        },
        edges: {
            ok: "update",
            retry: "retry",
            end: END
        }
    } as any)
    .addConditionalEdges("retry", {
        condition: (state) => {
            const { invocation_result, invocation_retry_policy } = state;
            if (invocation_result?.success === true) {
                return 'ok';
            } else if (invocation_result?.success === false && invocation_result.error_type === 'parseError' && invocation_result?.trial_count < invocation_retry_policy?.maximum_trial) {
                return 'retry';
            } else {
                return 'end';
            }
        },
        edges: {
            ok: "update", 
            retry: "retry",
            end: END
        }
    } as any)
    .compile();
    return graph;
}

StackTrace

Error: Invalid StateGraph input.
    at new StateGraph (C:\workspace\my-app\app\background.js:42808:19)
    at createGhostGraph (C:\workspace\my-app\app\background.js:248:17)
    at new Ghost (C:\workspace\my-app\app\background.js:298:18)
    at C:\workspace\my-app\app\background.js:72102:15
    at C:\workspace\my-app\app\background.js:72504:3
    at C:\workspace\my-app\background.js:72507:12
    at webpackUniversalModuleDefinition (C:\workspace\my-app\app\background.js:3:20)
    at Object.<anonymous> (C:\workspace\my-app\app\background.js:10:3)
    at Module._compile (node:internal/modules/cjs/loader:1544:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1629:10)
Originally created by @zerobell-lee on GitHub (Apr 27, 2025). # Stack - nextron(next.js + electron) + langgraph + langchain # Symptom - Cannot create StateGraph and it gives useless error message. - The error message is `Error: Invalid StateGraph input.` # Details - I'm trying migration to Langgraph from Langchian. - I made a `StateGraph` and called the function, but it failed. - Then I got error message `Error: Invalid StateGraph input.` . Not directing which value, and how it is wrong. - I don't think this is quite different from `UNKNOWN ERROR : post issue report langgraph community` - So please consider elaborating error messages. Thank you. # Code blocks ```typescript // some lines are skipped export const createGhostGraph = () => { const initialState: GhostState = { input: { input: "", isSystemMessage: false }, character_setting: {} as CharacterSetting, user_setting: {} as any, llmProperties: { llmService: "", modelName: "", apiKey: "", temperature: 0 }, executor: null, aiResponseParser: new AIResponseParser('openai'), invocation_result: null, invocation_retry_policy: { maximum_trial: 3 }, llm_response: null, chat_history: new AkagakuChatHistory([], 100), update_payload: null, final_response: null, tools: [] }; const graph = new StateGraph<GhostState>(initialState as any) .addNode("input", InputNode) .addNode("agent", AgentNode) .addNode("update", UpdateNode) .addNode("response", ResponseNode) .addNode("retry", RetryNode) .addEdge(START, "input") .addEdge("input", "agent") .addEdge("agent", "response") .addEdge("response", "update") .addEdge("update", END) .addConditionalEdges("response", { condition: (state) => { console.log('state', state) const { invocation_result, invocation_retry_policy } = state; if (invocation_result?.success === true) { return 'ok'; } else if (invocation_result?.success === false && invocation_result.error_type === 'parseError' && invocation_result?.trial_count < invocation_retry_policy?.maximum_trial) { return 'retry'; } else { return 'end'; } }, edges: { ok: "update", retry: "retry", end: END } } as any) .addConditionalEdges("retry", { condition: (state) => { const { invocation_result, invocation_retry_policy } = state; if (invocation_result?.success === true) { return 'ok'; } else if (invocation_result?.success === false && invocation_result.error_type === 'parseError' && invocation_result?.trial_count < invocation_retry_policy?.maximum_trial) { return 'retry'; } else { return 'end'; } }, edges: { ok: "update", retry: "retry", end: END } } as any) .compile(); return graph; } ``` # StackTrace ``` Error: Invalid StateGraph input. at new StateGraph (C:\workspace\my-app\app\background.js:42808:19) at createGhostGraph (C:\workspace\my-app\app\background.js:248:17) at new Ghost (C:\workspace\my-app\app\background.js:298:18) at C:\workspace\my-app\app\background.js:72102:15 at C:\workspace\my-app\app\background.js:72504:3 at C:\workspace\my-app\background.js:72507:12 at webpackUniversalModuleDefinition (C:\workspace\my-app\app\background.js:3:20) at Object.<anonymous> (C:\workspace\my-app\app\background.js:10:3) at Module._compile (node:internal/modules/cjs/loader:1544:14) at Module._extensions..js (node:internal/modules/cjs/loader:1629:10) ```
yindo closed this issue 2026-02-15 18:14:55 -05:00
Author
Owner

@hinthornw commented on GitHub (Apr 27, 2025):

Thanks for raising!

What was the input you provided when invoking the graph that triggered the error?

@hinthornw commented on GitHub (Apr 27, 2025): Thanks for raising! What was the input you provided when invoking the graph that triggered the error?
Author
Owner

@zerobell-lee commented on GitHub (Apr 27, 2025):

You mean, all state? or just input?

@zerobell-lee commented on GitHub (Apr 27, 2025): You mean, all state? or just `input`?
Author
Owner

@zerobell-lee commented on GitHub (Apr 27, 2025):

And this fails even to create graph. So I don't think what input I put is not related with this issue.

@zerobell-lee commented on GitHub (Apr 27, 2025): And this fails even to create graph. So I don't think what `input` I put is not related with this issue.
Author
Owner

@hinthornw commented on GitHub (Apr 27, 2025):

Ah helpful! That is indeed a confusing error message :) I had interpreted "called the function" as "invoke()" - cc

@hinthornw commented on GitHub (Apr 27, 2025): Ah helpful! That is indeed a confusing error message :) I had interpreted "called the function" as "invoke()" - cc
Author
Owner

@benjamincburns commented on GitHub (Apr 27, 2025):

Thanks for reporting this @zerobell-lee. Unfortunately it's a bit hard to see what's happening here as the code you shared is only a partial example. Would you be wiling to share a more complete minimal reproducible example that demonstrates this issue, please? Please limit the example to just the details necessary to reproduce the problem that you're encountering.

@benjamincburns commented on GitHub (Apr 27, 2025): Thanks for reporting this @zerobell-lee. Unfortunately it's a bit hard to see what's happening here as the code you shared is only a partial example. Would you be wiling to share a more complete [minimal reproducible example](https://en.wikipedia.org/wiki/Minimal_reproducible_example) that demonstrates this issue, please? Please limit the example to just the details necessary to reproduce the problem that you're encountering.
Author
Owner

@zerobell-lee commented on GitHub (Apr 29, 2025):

@hinthornw @benjamincburns Thanks for immediate support.

I want to reproduce this scenario and offer simplified code snippet. But please understand me that I have to work in weekdays. I'll try this issue when I'm free.

By the way, after all I solved this issue by using Annotation.Root() , just illustrated in official doc.
Still I don't get it how it works and the best practice to use CompiledStateGraph. So I'll study it later.

Thank you.

@zerobell-lee commented on GitHub (Apr 29, 2025): @hinthornw @benjamincburns Thanks for immediate support. I want to reproduce this scenario and offer simplified code snippet. But please understand me that I have to work in weekdays. I'll try this issue when I'm free. By the way, after all I solved this issue by using `Annotation.Root()` , just illustrated in official doc. Still I don't get it how it works and the best practice to use `CompiledStateGraph`. So I'll study it later. Thank you.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#238