langgraph

A guide for building AI agents and workflows in Python with LangGraph, a framework for connecting model calls, tools, and stateful steps. It covers simpler agents and custom graph-based workflows.

In plain words
What is it for?
Use it when creating tool-using agents, multi-agent systems, conditional workflows, persistent conversations, or human-in-the-loop processes.
Why use it?
It helps choose an appropriate LangGraph approach and avoid common mistakes with state, memory, streaming, and human approval steps.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/codeblockz/langchain-community-plugin/langgraph
Any agent
npx skills add Codeblockz/langchain-community-plugin --skill langgraph
Clone the repo
git clone --depth 1 https://github.com/Codeblockz/langchain-community-plugin

Made for: Claude Code, Codex.

Per session 60 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,314 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00060 $0.01314
Opus 5 $0.00030 $0.00657
Sonnet 5 $0.00012 $0.00263
Haiku 4.5 $0.00006 $0.00131

Measured yesterday against content hash 370f4a229eaa, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

langgraph scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/langgraph/SKILL.md · 177 lines

How it starts

The opening of the file, as written. The whole thing — 177 lines — stays where its author put it; the contents beside it link to each section on GitHub.

LangGraph Agent Builder

Quick Decision: Which API?

Use create_agent when... Use StateGraph when...
Building standard tool-calling agents Need custom node logic or routing
Want middleware (HITL, guardrails) Building multi-agent systems
Prefer minimal boilerplate Need fine-grained state control
Standard ReAct pattern suffices Complex conditional workflows

create_agent Quick Start

from langchain.agents import create_agent
from langchain.tools import tool
from langgraph.checkpoint.memory import InMemorySaver

@tool
def search(query: str) -> str:
    """Search for information."""
    return f"Results for: {query}"

agent = create_agent(
    model="claude-sonnet-4-5-20250929",
    tools=[search],
    system_prompt="You are a helpful assistant.",
    checkpointer=InMemorySaver(),  # Required for memory/HITL
)

# Invoke with thread_id for conversation memory
result = agent.invoke(
    {"messages": [{"role": "user", "content": "Search for LangGraph docs"}]},
    config={"configurable": {"thread_id": "user-123"}}
)

StateGraph Quick Start

from typing import Annotated
from typing_extensions import TypedDict
from langchain.messages import AnyMessage
from langchain.chat_models import init_chat_model
from langchain.tools import tool
from langgraph.graph import StateGraph, START, END
from langgraph.graph.message import add_messages
from langgraph.checkpoint.memory import InMemorySaver

# 1. Define state - MUST be TypedDict
class State(TypedDict):
    messages: Annotated[list[AnyMessage], add_messages]  # Reducer appends

# 2. Define tools
@tool
def multiply(a: int, b: int) -> int:
    """Multiply two numbers."""
    return a * b

tools = [multiply]
model = init_chat_model("claude-sonnet-4-5-20250929").bind_tools(tools)

# 3. Define nodes
def call_model(state: State):
    return {"messages": [model.invoke(state["messages"])]}

def call_tools(state: State):
    from langchain.messages import ToolMessage
    last = state["messages"][-1]
    results = []
    for tc in last.tool_calls:
        tool_fn = {t.name: t for t in tools}[tc["name"]]
        results.append(ToolMessage(content=str(tool_fn.invoke(tc["args"])), tool_call_id=tc["id"]))
    return {"messages": results}

# 4. Define routing
def should_continue(state: State):
    if state["messages"][-1].tool_calls:
        return "tools"
    return END

# 5. Build graph
graph = (
    StateGraph(State)
    .add_node("model", call_model)
    .add_node("tools", call_tools)
    .add_edge(START, "model")
    .add_conditional_edges("model", should_continue, ["tools", END])
    .add_edge("tools", "model")
    .compile(checkpointer=InMemorySaver())
)

Read the full file on GitHub · 177 lines

Files

What ships with it

5 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 177 lines · 60 tokens per session scan A 370f4a229eaa

Subscribe to this mod's changes

langgraph is a skill published in the GitHub repository Codeblockz/langchain-community-plugin (3 stars, last pushed 7mo ago), licensed Apache-2.0. It adds 60 tokens to every session and 1,314 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

skill-creator

Guide for creating effective skills that extend agent capabilities with specialized knowledge, workflows, or tool integrations. Use this skill when the user asks to: (1) create a new skill, (2) make a skill, (3) build a skill, (4) set up a skill, (5) initialize a skill, (6) scaffold a skill, (7) update or modify an…

langchain-ai/deepagents · 159 tokens

blog_creator

创作高质量的技术博客文章。擅长将复杂的技术概念转化为通俗易懂的内容,结构清晰,案例丰富,适合不同层次的技术读者。.

liuyueyi/spring-ai-demo · 48 tokens

skill-creator

Guide for creating effective skills that extend DAIV agent with specialized knowledge, workflows, or tool integrations. Use this skill when the user wants to create a new skill, update an existing skill, or get guidance on skill design patterns.

srtab/daiv · 50 tokens

data-visualization

Use for creating publication-quality charts and multi-panel analysis summaries. Triggers when tasks involve visualizing data, plotting results, creating charts, or producing visual reports from analysis output.

langchain-ai/deepagents · 40 tokens

cuml-machine-learning

Use for GPU-accelerated machine learning on tabular data using NVIDIA cuML. Triggers when tasks involve classification, regression, clustering, dimensionality reduction, or model training on datasets.

langchain-ai/deepagents · 43 tokens

blog-post

Writes and structures long-form blog posts, creates tutorial outlines, and optimizes content for SEO with cover image generation. Use when the user asks to write a blog post, article, how-to guide, tutorial, technical writeup, thought leadership piece, or long-form content.

langchain-ai/deepagents · 58 tokens