Skip to content

Langgraph react agent

LangGraph ReAct Agent implementation.

A ReAct agent template built on LangGraph that can use either lm_invoker or LangChain BaseChatModel.

Authors

Christian Trisno Sen Long Chen (christian.t.s.l.chen@gdplabs.id) Fachriza Adhiatma (fachriza.d.adhiatma@gdplabs.id)

LangChainAgent(name, instruction=DEFAULT_INSTRUCTION, model=None, tools=None, agents=None, description=None, thread_id_key='thread_id', event_emitter=None, **kwargs)

Bases: LangGraphReactAgent

Alias for LangGraphReactAgent.

Initialize the LangGraph ReAct Agent.

Parameters:

Name Type Description Default
name str

The name of the agent.

required
instruction str

The system instruction for the agent.

DEFAULT_INSTRUCTION
model BaseChatModel | str | Any | None

The model to use (lm_invoker, LangChain model, string, etc.).

None
tools Sequence[BaseTool] | None

Sequence of LangChain tools available to the agent.

None
agents Sequence[Any] | None

Optional sequence of sub-agents for delegation (coordinator mode).

None
description str | None

Human-readable description of the agent.

None
thread_id_key str

Key for thread ID in configuration.

'thread_id'
event_emitter EventEmitter | None

Optional event emitter for streaming updates.

None
**kwargs Any

Additional keyword arguments passed to BaseLangGraphAgent.

{}

LangGraphAgent(name, instruction=DEFAULT_INSTRUCTION, model=None, tools=None, agents=None, description=None, thread_id_key='thread_id', event_emitter=None, **kwargs)

Bases: LangGraphReactAgent

Alias for LangGraphReactAgent.

Initialize the LangGraph ReAct Agent.

Parameters:

Name Type Description Default
name str

The name of the agent.

required
instruction str

The system instruction for the agent.

DEFAULT_INSTRUCTION
model BaseChatModel | str | Any | None

The model to use (lm_invoker, LangChain model, string, etc.).

None
tools Sequence[BaseTool] | None

Sequence of LangChain tools available to the agent.

None
agents Sequence[Any] | None

Optional sequence of sub-agents for delegation (coordinator mode).

None
description str | None

Human-readable description of the agent.

None
thread_id_key str

Key for thread ID in configuration.

'thread_id'
event_emitter EventEmitter | None

Optional event emitter for streaming updates.

None
**kwargs Any

Additional keyword arguments passed to BaseLangGraphAgent.

{}

LangGraphReactAgent(name, instruction=DEFAULT_INSTRUCTION, model=None, tools=None, agents=None, description=None, thread_id_key='thread_id', event_emitter=None, **kwargs)

Bases: BaseLangGraphAgent

A ReAct agent template built on LangGraph.

This agent can use either: - An LMInvoker (if self.lm_invoker is set by BaseAgent) - A LangChain BaseChatModel (if self.model is set by BaseAgent)

The graph structure follows the standard ReAct pattern: agent -> tools -> agent (loop) -> END

Initialize the LangGraph ReAct Agent.

Parameters:

Name Type Description Default
name str

The name of the agent.

required
instruction str

The system instruction for the agent.

DEFAULT_INSTRUCTION
model BaseChatModel | str | Any | None

The model to use (lm_invoker, LangChain model, string, etc.).

None
tools Sequence[BaseTool] | None

Sequence of LangChain tools available to the agent.

None
agents Sequence[Any] | None

Optional sequence of sub-agents for delegation (coordinator mode).

None
description str | None

Human-readable description of the agent.

None
thread_id_key str

Key for thread ID in configuration.

'thread_id'
event_emitter EventEmitter | None

Optional event emitter for streaming updates.

None
**kwargs Any

Additional keyword arguments passed to BaseLangGraphAgent.

{}

define_graph(graph_builder)

Define the ReAct agent graph structure.

Parameters:

Name Type Description Default
graph_builder StateGraph

The StateGraph builder to define the graph structure.

required

Returns:

Type Description
CompiledStateGraph

Compiled LangGraph ready for execution.

ReactAgentState

Bases: TypedDict

State schema for the ReAct agent.

Includes messages, step tracking, optional event emission support, artifacts, references, and metadata.