# langgraph > Python-only LangGraph skill for building stateful agents and workflows with memory, human-in-the-loop, streaming, persistence, time travel, and deployment. Use when orchestrating agents in Python with LangGraph/LangChain/LangSmith; includes API reference, scenarios, and troubleshooting. - Author: cincly - Repository: rzte/skills - Version: 20251222100700 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-07 - Source: https://github.com/rzte/skills - Web: https://mule.run/skillshub/@@rzte/skills~langgraph:20251222100700 --- --- name: langgraph description: "Python-only LangGraph skill for building stateful agents and workflows with memory, human-in-the-loop, streaming, persistence, time travel, and deployment. Use when orchestrating agents in Python with LangGraph/LangChain/LangSmith; includes API reference, scenarios, and troubleshooting." --- # LangGraph (Python) Skill This skill equips Claude to design and implement Python agents and workflows using LangGraph. It provides concise guidance, API references, runnable examples, and troubleshooting scripts with progressive disclosure to keep context lean. ## Installation (Python only) Prefer the mirror for pip installations: ```bash pip install -i https://repo.huaweicloud.com/repository/pypi/simple/ -U langgraph # Optional companions pip install -i https://repo.huaweicloud.com/repository/pypi/simple/ -U langchain langchain-community langchain-openai # Checkpointers (choose one as needed) pip install -i https://repo.huaweicloud.com/repository/pypi/simple/ -U langgraph-checkpoint-postgres pip install -i https://repo.huaweicloud.com/repository/pypi/simple/ -U langgraph-checkpoint-mongodb pip install -i https://repo.huaweicloud.com/repository/pypi/simple/ -U langgraph-checkpoint-redis ``` - Use Graph API for stateful, multi-step agent loops with nodes/edges and memory. - Use Functional API for deterministic workflows that compose tasks with @entrypoint and @task. ## Core Concepts Overview - Graph API: StateGraph, nodes, edges (including conditional), reducers, MessagesState, compile/invoke/stream. - Functional API: @entrypoint, @task, interrupt and Command to pause/resume, streaming. - Persistence: Checkpointers (InMemorySaver, Postgres/MongoDB/Redis), threads and thread_id requirement. - Memory: Short-term (thread-scoped) via checkpoints and MessagesState; long-term via Store. - Streaming: values, updates, custom, messages, debug; synchronous/asynchronous. - Time travel: get_state, get_state_history, update_state to inspect and edit state. For detailed parameters and return types, see resources/api_list.json. ## Quickstart Start with the calculator agent example: see resources/quickstart_calculator.py. The minimal pattern is: ```python from langgraph.graph import StateGraph, START, END, MessagesState from langgraph.checkpoint.memory import InMemorySaver def call_model(state: MessagesState) -> MessagesState: # ... call your model and append a message ... return state builder = StateGraph(MessagesState) builder.add_node("call_model", call_model) builder.add_edge(START, "call_model") builder.add_edge("call_model", END) graph = builder.compile(checkpointer=InMemorySaver()) result = graph.invoke( {"messages": [{"role": "user", "content": "hi"}]}, {"configurable": {"thread_id": "thread-1"}} ) ``` ## Core APIs (use this selection guidance) - StateGraph: Define state schema (TypedDict/dataclass/Pydantic) and reducers; add_node/add_edge/add_conditional_edges; compile() to runnable. - MessagesState: Built-in message reducer via add_messages to preserve conversation. - Functional API: Decorate with @task for side-effecting or non-deterministic work; orchestrate with @entrypoint; IO must be JSON-serializable. - Persistence: InMemorySaver for ephemeral; Postgres/MongoDB/Redis for durable checkpoints; always pass {"configurable": {"thread_id": "..."} } when invoking a checkpointed graph. - Interrupts: interrupt() pauses and returns control; resume with Command(resume=...); node restarts on resume. - Streaming: graph.stream()/graph.astream() with modes: "values", "updates", "custom", "messages", "debug". - Time travel: get_state(), get_state_history(), update_state() for inspection and partial execution. For full parameter/type enumerations, load resources/api_list.json. ## Scenarios and Patterns - Calculator agent (Graph API): resources/quickstart_calculator.py - Agentic RAG (Graph API): resources/agentic_rag.py - SQL agent (Graph API + HITL): resources/sql_agent.py - Memory patterns: resources/memory_short_term.py and resources/memory_long_term.py - Functional workflow with interrupt/review: resources/functional_interrupt.py - Streaming usage: resources/streaming_examples.py Each file contains step-by-step instructions and runnable, minimal code. ## Exceptions and Troubleshooting Common pitfalls: 1. Missing configurable.thread_id when using checkpointers (cannot persist/resume). 2. Forgetting builder.compile() before invoke/stream. 3. EntryPoint IO not JSON-serializable (serialization errors). 4. DB-backed saver not setup() on first use (Postgres/Mongo/Redis). 5. Messages overwritten when reducers not set (use add_messages). 6. Non-deterministic operations not isolated in @task. 7. Provider timeouts / tool-call errors not surfaced to LLM loop. Scripts to help: - scripts/check_thread_id.py — validate {"configurable": {"thread_id": ...}} in runtime config. - scripts/init_postgres_checkpointer.py — initialize and test PostgresSaver connectivity. - scripts/serialization_guard.py — check JSON-serializability of inputs/outputs for @entrypoint. ## References Load detailed guides as needed: - references/graph_api.md — state, nodes/edges, reducers, compile/invoke. - references/functional_api.md — @entrypoint, @task, interrupt/Command, streaming. - references/memory_persistence.md — checkpointers, threads, stores. - references/interrupts.md — human-in-the-loop patterns. - references/streaming.md — modes, subgraph streaming. - references/time_travel.md — get_state, history, update_state patterns. - references/deploy.md — local server, Studio, LangSmith. - references/troubleshooting.md — errors and solutions. ## Usage Notes - Keep SKILL.md lean; load references only when necessary. - Prefer deterministic scripts for fragile operations; otherwise follow the guided steps. - For Python package installations, prefer the specified mirror. ## Triggering Guidance This skill should be used when: - Building agent loops or workflows with LangGraph in Python. - Adding memory, HITL, streaming, or persistence to agents. - Troubleshooting LangGraph runtime behavior or DB-backed checkpoints. - Choosing between Graph API and Functional API for a task. See resources/api_list.json and the scenario files for concrete, runnable patterns.