🌐
Langchain
reference.langchain.com › python › langgraph › graph › state › StateGraph
StateGraph | langgraph | LangChain Reference
from langchain_core.runnables import RunnableConfig from typing_extensions import Annotated, TypedDict from langgraph.checkpoint.memory import InMemorySaver from langgraph.graph import StateGraph from langgraph.runtime import Runtime def reducer(a: list, b: int | None) -> list: if b is not None: return a + [b] return a class State(TypedDict): x: Annotated[list, reducer] class Context(TypedDict): r: float graph = StateGraph(state_schema=State, context_schema=Context) def node(state: State, runtime: Runtime[Context]) -> dict: r = runtime.context.get("r", 1.0) x = state["x"][-1] next_value = x * r * (1 - x) return {"x": next_value} graph.add_node("A", node) graph.set_entry_point("A") graph.set_finish_point("A") compiled = graph.compile() step1 = compiled.invoke({"x": 0.5}, context={"r": 3.0}) # {'x': [0.5, 0.75]}
🌐
LangChain
langchain-ai.github.io › langgraphjs › reference › classes › langgraph.StateGraph.html
StateGraph | LangGraph.js API Reference
Overrides Graph<N, S, U, StateGraphNodeSpec<S, U>, ToStateDefinition<C>>.constructor · Defined in libs/langgraph-core/dist/graph/state.d.ts:163
🌐
Langchain
docs.langchain.com › oss › python › langgraph › graph-api
Graph API overview - Docs by LangChain
Edges: Functions that determine which Node to execute next based on the current state. They can be conditional branches or fixed transitions. By composing Nodes and Edges, you can create complex, looping workflows that evolve the state over time. The real power, though, comes from how LangGraph manages that state.
🌐
Medium
medium.com › ai-agents › langgraph-for-beginners-part-4-stategraph-794004555369
LangGraph for Beginners, Part 4: StateGraph. | by Santosh Rout | AI Agents | Medium
October 26, 2024 - State is one of the core components of LangGraph. A node takes state as input, updates it and pass it to the next node in the graph. So the next node takes the response from the previous node as input, updates it and pass it onto the next one.
🌐
PyPI
pypi.org › project › langgraph › 0.0.23
langgraph · PyPI
LangGraph is a library for building stateful, multi-actor applications with LLMs, built on top of (and intended to be used with) LangChain. It extends the LangChain Expression Language with the ability to coordinate multiple chains (or actors) ...
      » pip install langgraph
    
Published   Feb 04, 2024
Version   0.0.23
🌐
LangChain
blog.langchain.com › langgraph
LangGraph
January 17, 2024 - At it's core, LangGraph exposes a pretty narrow interface on top of LangChain. StateGraph is a class that represents the graph. You initialize this class by passing in a state definition.
🌐
Langchain
reference.langchain.com › javascript › langchain-langgraph › index › StateGraph
StateGraph | @langchain/langgraph | LangChain Reference
import { type BaseMessage, AIMessage, HumanMessage, } from "@langchain/core/messages"; import { StateGraph, Annotation } from "@langchain/langgraph"; // Define a state with a single key named "messages" that will // combine a returned BaseMessage or arrays of BaseMessages const StateAnnotation = Annotation.Root({ sentiment: Annotation<string>, messages: Annotation<BaseMessage[]>({ reducer: (left: BaseMessage[], right: BaseMessage | BaseMessage[]) => { if (Array.isArray(right)) { return left.concat(right); } return left.concat([right]); }, default: () => [], }), }); const graphBuilder = new StateGraph(StateAnnotation); // A node in the graph that returns an object with a "messages" key // will update the state by combining the existing value with the returned one.
🌐
Medium
medium.com › @diwakarkumar_18755 › understanding-langgraphs-stategraph-a-simple-guide-020f70fc0038
Understanding LangGraph’s StateGraph: A Simple Guide | by Diwakar Kumar | Medium
March 24, 2025 - LangGraph is a powerful framework that allows developers to define workflows as directed graphs. One of its core components is StateGraph, which enables efficient state management and execution flow control.
Find elsewhere
🌐
Medium
medium.com › @gitmaxd › understanding-state-in-langgraph-a-comprehensive-guide-191462220997
Understanding State in LangGraph: A Beginners Guide 🚀 | by Rick Garcia | Medium
August 17, 2024 - This simple graph demonstrates the fundamental structure of a LangGraph workflow: We create a StateGraph using our BasicState.
🌐
Substack
iaee.substack.com › p › langgraph-intuitively-and-exhaustively
LangGraph — Intuitively and Exhaustively Explained
September 5, 2024 - Once we understand why LangGraph exists, we’ll explore the technology practically through something called a “State Graph”. We’ll use this state graph to build an agent which is capable of performing a complex task which requires the agent to deal with natural conversation, hard rules, and application logic.
🌐
GitHub
github.com › langchain-ai › langgraph
GitHub - langchain-ai/langgraph: Build resilient language agents as graphs. · GitHub
3 days ago - Trusted by companies shaping the future of agents – including Klarna, Replit, Elastic, and more – LangGraph is a low-level orchestration framework for building, managing, and deploying long-running, stateful agents.
Starred by 30.9K users
Forked by 5.3K users
Languages   Python
🌐
Baihezi
baihezi.com › mirrors › langgraph › reference › graphs › index.html
Graphs - LangGraph
Graphs are the core abstraction of LangGraph. Each StateGraph implementation is used to create graph workflows.
🌐
GettingStarted.ai
gettingstarted.ai › langgraph-tutorial-with-example
LangGraph Tutorial with Practical Example
November 24, 2024 - For example, a node can integrate with a large language model, process information, call an external API, or any other task. A LangGraph node takes the state of the graph as a parameter and returns an updated state after it is executed.
🌐
Real Python
realpython.com › langgraph-python
LangGraph: Build Stateful AI Agents in Python – Real Python
November 15, 2024 - LangGraph is a versatile Python library designed for stateful, cyclic, and multi-actor Large Language Model (LLM) applications. This tutorial will give you an overview of LangGraph fundamentals through hands-on examples, and the tools needed ...
🌐
Medium
medium.com › @martin.hodges › defining-the-langgraph-state-47c5ef97a95c
Defining the LangGraph state. In a previous article, I introduced a… | by Martin Hodges | Medium
September 9, 2025 - StateGraph returns a builder for the graph. Note the difference between the LangGraph StateGraph and the state type GraphState!
🌐
DEV Community
dev.to › jamesli › langgraph-state-machines-managing-complex-agent-task-flows-in-production-36f4
LangGraph State Machines: Managing Complex Agent Task Flows in Production - DEV Community
November 19, 2024 - LangGraph helps us manage such workflows efficiently. States are like checkpoints in your task execution: from typing import TypedDict, List class ShoppingState(TypedDict): # Current state current_step: str # Cart items cart_items: List[str] # Total amount total_amount: float # User input user_input: str class ShoppingGraph(StateGraph): def __init__(self): super().__init__() # Define states self.add_node("browse", self.browse_products) self.add_node("add_to_cart", self.add_to_cart) self.add_node("checkout", self.checkout) self.add_node("payment", self.payment)