TOOL WIKI · AGENT SDKS

LangGraph

Represents an agent or workflow as explicit state and transitions in a graph.

Download example files Code + setup + checks in a ZIP
Jump to a section 10 sections

EXAMPLE USE CASE

Own the transitions in an order lookup loop

A developer needs a small, observable agent or retrieval step before connecting real business services.

Input
MessagesState, a model node, ToolNode and a bounded recursion limit.
Expected output
A model → tool → model path ending in the observed order status.
  • Success check: The messages end with an answer grounded in the tool result.
  • Try a failure: A repeated request must stop at the configured recursion bound.

Example scope: Actual graph invocation; state is process-local without a checkpointer.

Official reference · LangGraph

WHAT IT ISOrchestration framework
WHERE IT FITSAgent SDKs
SEE HOW THE SYSTEM FITS TOGETHERSELECT A COMPONENT
taskinvokedecisiontool callresultstatemeasureApplicationTask + identityLangGraphOrchestration frameworkModel providerConfigured API modelTool serviceAuthorization + executionState storageRun and thread progressEvaluationOutcome + evidence
  1. Authenticate the request and define the goal before calling the framework.

  2. Custom control flow, branching, interruptions, and persisted execution. A checkpoint does not make an external side effect safe to repeat.

  3. The application supplies provider credentials, model selection, and budgets.

  4. Validate each operation and return authoritative observations.

  5. Choose the checkpoint or session store and its retention policy deliberately.

    Result or stopping point
  6. Check completion, cost, latency, and tool behavior against fixtures.

    Result or stopping point
LangGraph

Custom control flow, branching, interruptions, and persisted execution. A checkpoint does not make an external side effect safe to repeat.

Follow the arrows, then select a component to inspect its responsibility. On mobile, downward arrows connect the next step; bent arrows identify branches and return paths. Select a destination to jump to that component.

When to consider it

  • Custom control flow, branching, interruptions, and persisted execution.

A design decision to make

  • A checkpoint does not make an external side effect safe to repeat.

Prerequisites and setup

  • Python 3.11+ in an empty directory. A compatible model and provider credentials are required.
  • Running the model-backed example can incur API charges; this website displays it without calling a provider.
  • Save the code at the displayed path, then use the corresponding run command.
Shell
python3 -m venv .venv
source .venv/bin/activate
python -m pip install langgraph langchain langchain-openai
export OPENAI_API_KEY="your-api-key"
export OPENAI_MODEL="your-enabled-model-id"

Try a small integration

graph_agent.py

Python · graph_agent.py
import os
from langchain.chat_models import init_chat_model
from langchain.tools import tool
from langgraph.graph import StateGraph, MessagesState, START
from langgraph.prebuilt import ToolNode, tools_condition

@tool
def lookup_order(order_id: str) -> str:
    """Read an order status from a local demonstration fixture."""
    orders = {"A104": "Packed; awaiting courier pickup"}
    return orders.get(order_id, "Order not found")

tools = [lookup_order]
model = init_chat_model(
    os.environ["OPENAI_MODEL"], model_provider="openai"
).bind_tools(tools)

def think(state: MessagesState):
    response = model.invoke(state["messages"])
    return {"messages": [response]}

builder = StateGraph(MessagesState)
builder.add_node("think", think)
builder.add_node("tools", ToolNode(tools))
builder.add_edge(START, "think")
builder.add_conditional_edges("think", tools_condition)
builder.add_edge("tools", "think")
agent = builder.compile()

result = agent.invoke(
    {"messages": [("user", "Use lookup_order for A104.")]},
    {"recursion_limit": 8},
)
print(result["messages"][-1].content)

Run and check the result

Shell
python graph_agent.py
  • The messages end with an answer grounded in the tool result.
  • The graph moves from think to tools and back, then stops when no tool is requested.

Common failures

  • A missing ToolMessage or mismatched call identifier breaks the tool-result contract.
  • A recursion-limit failure is evidence of an unfinished loop; inspect repeated tool calls before raising the limit.

Production decisions

  • Replace the local fixture with a service that enforces authenticated tenant and resource permissions.
  • Add timeouts, bounded retries, tracing redaction, and a regression case for each observed failure.
  • Model calls consume provider API usage when you run this example; this website only displays the code.
Read the LangGraph walkthrough

Keep exploring

Workflow, single agent, or multiple agents?Build an explicit agent loop with LangGraph

Explore the same layer

OpenAI Agents SDKClaude Agent SDKGoogle ADKLangChain

Compare candidates on your own workload. This entry describes a product’s role; it is not a claim that products in the category are interchangeable.