Skip to content

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

@Aitosoft

Description

@Aitosoft

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

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