createAgent can't be used as a StateGraph node - Python parity issue #375

Open
opened 2026-02-15 18:16:19 -05:00 by yindo · 2 comments
Owner

Originally created by @Aitosoft on GitHub (Nov 2, 2025).

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangGraph.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangGraph.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangGraph (or the specific integration package).

Example Code

import { createAgent } from 'langchain';
import { StateGraph, Annotation } from '@langchain/langgraph';
import { ChatOpenAI } from '@langchain/openai';

const agent = createAgent({
model: new ChatOpenAI({ model: 'gpt-4o-mini' }),
tools: [],
name: 'MyAgent',
});

const State = Annotation.Root({
messages: Annotation<any[]>({ reducer: (a, b) => a.concat(b) }),
});

const workflow = new StateGraph(State)
.addNode('agent', agent); // fails here

const graph = workflow.compile();

Error Message and Stack Trace (if applicable)

error TS2769: No overload matches this call.

Argument of type 'ReactAgent<...>' is not assignable to parameter of type 'NodeAction<...>'
Index signature for type 'string' is missing in type 'ReactAgent<...>'

Description

Greetings,

Running into an issue trying to use createAgent as a node in a larger workflow. Blog/docs say we should be able to "start simple and drop down to LangGraph when needed" but the agent returned by createAgent doesn't work with StateGraph.addNode().

In Python this just works. In JS seems like ReactAgent isn't compatible with what addNode expects. Having to write everything as custom StateGraphs kinda defeats the purpose of the helpers. Would love to just drop readymade agents to my custom workflows, so looking forward to the fix :)

Am I missing something or is this a known gap? Related to #1739 maybe?

System Info

Node version: v22.16.0
Operating system: linux arm64
Package manager: pnpm
Package manager version: 10.11.0

@langchain/core -> 1.0.2
langsmith -> 0.3.74
zod -> 4.1.11
@langchain/google-genai -> 0.2.18
@langchain/langgraph -> 1.0.1
@langchain/langgraph-checkpoint -> 0.1.1
@langchain/langgraph-checkpoint-postgres -> 0.1.2
@langchain/openai -> 1.0.0
langchain -> 1.0.2

Originally created by @Aitosoft on GitHub (Nov 2, 2025). ### Checked other resources - [x] I added a very descriptive title to this issue. - [x] I searched the LangGraph.js documentation with the integrated search. - [x] I used the GitHub search to find a similar question and didn't find it. - [x] I am sure that this is a bug in LangGraph.js rather than my code. - [x] The bug is not resolved by updating to the latest stable version of LangGraph (or the specific integration package). ### Example Code import { createAgent } from 'langchain'; import { StateGraph, Annotation } from '@langchain/langgraph'; import { ChatOpenAI } from '@langchain/openai'; const agent = createAgent({ model: new ChatOpenAI({ model: 'gpt-4o-mini' }), tools: [], name: 'MyAgent', }); const State = Annotation.Root({ messages: Annotation<any[]>({ reducer: (a, b) => a.concat(b) }), }); const workflow = new StateGraph(State) .addNode('agent', agent); // fails here const graph = workflow.compile(); ### Error Message and Stack Trace (if applicable) error TS2769: No overload matches this call. Argument of type 'ReactAgent<...>' is not assignable to parameter of type 'NodeAction<...>' Index signature for type 'string' is missing in type 'ReactAgent<...>' ### Description Greetings, Running into an issue trying to use createAgent as a node in a larger workflow. Blog/docs say we should be able to "start simple and drop down to LangGraph when needed" but the agent returned by createAgent doesn't work with StateGraph.addNode(). In Python this just works. In JS seems like ReactAgent isn't compatible with what addNode expects. Having to write everything as custom StateGraphs kinda defeats the purpose of the helpers. Would love to just drop readymade agents to my custom workflows, so looking forward to the fix :) Am I missing something or is this a known gap? Related to #1739 maybe? ### System Info Node version: v22.16.0 Operating system: linux arm64 Package manager: pnpm Package manager version: 10.11.0 -------------------- @langchain/core -> 1.0.2 langsmith -> 0.3.74 zod -> 4.1.11 @langchain/google-genai -> 0.2.18 @langchain/langgraph -> 1.0.1 @langchain/langgraph-checkpoint -> 0.1.1 @langchain/langgraph-checkpoint-postgres -> 0.1.2 @langchain/openai -> 1.0.0 langchain -> 1.0.2
Author
Owner

@Aitosoft commented on GitHub (Nov 20, 2025):

Why this matters

The LangChain 1.0 announcement states:

“Start with LangChain's high-level APIs and seamlessly drop down to LangGraph when you need more control. Since graphs are composable, you can mix both approaches—using agents created with create_agent inside custom LangGraph workflows.”

This core value proposition does not work in JavaScript today.

@Aitosoft commented on GitHub (Nov 20, 2025): ### Why this matters The LangChain 1.0 announcement states: > “Start with LangChain's high-level APIs and seamlessly drop down to LangGraph when you need more control. Since graphs are composable, you can mix both approaches—using agents created with create_agent inside custom LangGraph workflows.” This core value proposition does not work in JavaScript today.
Author
Owner

@qdhoward commented on GitHub (Dec 14, 2025):

I observed same issue.
Langchain version is

"@langchain/core": "^1.1.4",
 "@langchain/langgraph": "^1.0.4",
 "langchain": "^1.1.5",

I am using sonnet 4.5 model and streaming from the graph. The same pattern works before upgrading to 1.x.

I had a graph like this

new StateGraph(stateSchema).addNode('supervisor', this.supervisorAgent.graph, { ends: ['agent1', 'agent2', END] })
      .addNode('agent1', this.agent1.graph)
      .addNode('adGroupCreationAgent', this.agent2.graph)
      .addEdge(START, 'supervisor')
      .addEdge('agent1', END)
      .addEdge('agent2', END);

supervisor, agent1, and agent2 are instance of createAgent().
supervisor hands off task to agent1 and agent2 by using Command in a handoff tool

tool(
    async (_, runtime: ToolRuntime) => {
      const currentState = runtime.state;
      const toolMessage = new ToolMessage({
        content: `Successfully transferred to sub-agent ${agentName}`,
        name: toolName,
        tool_call_id: runtime.toolCallId,
      });

      return new Command({
        goto: agentName,
        update: { messages: currentState.messages.concat(toolMessage) },
        graph: Command.PARENT,
      });
    },
    {
      name: toolName,
      description,
      schema: z.object({}),
    },
  );

The handoff is successful. I can see message from subagent agent1 saying it got the handoff.
However, when agent1 invoked a tool to complete task then it gave an error.
Error is

ValidationException: Expected toolResult blocks at messages.0.content for the following Ids: tooluse_Llz0YfNRROOEi4pljVG3Cw

It seems the tool result is not picked up correctly by subagent graph.
I think this comment in another issue may be related
https://github.com/langchain-ai/langgraphjs/issues/1739#issuecomment-3556536876
The issue impacts the core value of langgraph and making langgraph not function with basic agent in langchain. Could someone have a look at this issue? Thanks!

@qdhoward commented on GitHub (Dec 14, 2025): I observed same issue. Langchain version is ``` "@langchain/core": "^1.1.4", "@langchain/langgraph": "^1.0.4", "langchain": "^1.1.5", ``` I am using sonnet 4.5 model and streaming from the graph. The same pattern works before upgrading to 1.x. I had a graph like this ``` new StateGraph(stateSchema).addNode('supervisor', this.supervisorAgent.graph, { ends: ['agent1', 'agent2', END] }) .addNode('agent1', this.agent1.graph) .addNode('adGroupCreationAgent', this.agent2.graph) .addEdge(START, 'supervisor') .addEdge('agent1', END) .addEdge('agent2', END); ``` supervisor, agent1, and agent2 are instance of createAgent(). supervisor hands off task to agent1 and agent2 by using Command in a handoff tool ``` tool( async (_, runtime: ToolRuntime) => { const currentState = runtime.state; const toolMessage = new ToolMessage({ content: `Successfully transferred to sub-agent ${agentName}`, name: toolName, tool_call_id: runtime.toolCallId, }); return new Command({ goto: agentName, update: { messages: currentState.messages.concat(toolMessage) }, graph: Command.PARENT, }); }, { name: toolName, description, schema: z.object({}), }, ); ``` The handoff is successful. I can see message from subagent agent1 saying it got the handoff. However, when agent1 invoked a tool to complete task then it gave an error. Error is ``` ValidationException: Expected toolResult blocks at messages.0.content for the following Ids: tooluse_Llz0YfNRROOEi4pljVG3Cw ``` It seems the tool result is not picked up correctly by subagent graph. I think this comment in another issue may be related https://github.com/langchain-ai/langgraphjs/issues/1739#issuecomment-3556536876 The issue impacts the core value of langgraph and making langgraph not function with basic agent in langchain. Could someone have a look at this issue? Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#375