[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M792BN05EETXV6ANS2BJ3T5D":3,"skill-same:01M792BN05EETXV6ANS2BJ3T5D":59},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":36,"commitSha":37,"skillDirectory":38,"forksCount":39,"repositoryHtmlUrl":40,"repositoryHomepageUrl":6,"ownerHtmlUrl":41,"ownerBlogUrl":42,"ownerDescription":43,"updatedAt":44,"install":45,"resources":58},"01M792BN05EETXV6ANS2BJ3T5D","langchain-langgraph-basics",null,"Build a correct LangGraph 1.0 StateGraph — typed TypedDict state with reducers,\nnodes, edges, compile, and recursion budgets — without hitting the silent-termination\nand state-replacement traps. Use when writing your first LangGraph StateGraph,\ndiagnosing why a graph halted without reaching END, or picking recursion_limit.\nTrigger with \"langgraph statgraph\", \"langgraph basics\", \"GraphRecursionError\",\n\"langgraph conditional edges\".","jukeyman\u002Fjukeyman-skills","jukeyman","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F142960420?v=4","01M78FR4Y3DHMMCBCC0GXXNB3F","RICK JEFFERSON","01M78FR4Z8RVQRAD31Y5J7V6EB",1,"MIT","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fsaas-packs--langchain-py-pack--langchain-langgraph-basics\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: langchain-langgraph-basics\ndescription: |\n  Build a correct LangGraph 1.0 StateGraph — typed TypedDict state with reducers,\n  nodes, edges, compile, and recursion budgets — without hitting the silent-termination\n  and state-replacement traps. Use when writing your first LangGraph StateGraph,\n  diagnosing why a graph halted without reaching END, or picking recursion_limit.\n  Trigger with \"langgraph statgraph\", \"langgraph basics\", \"GraphRecursionError\",\n  \"langgraph conditional edges\".\nallowed-tools: Read, Write, Edit, Bash(python:*)\nversion: 2.0.0\nlicense: MIT\nauthor: Jeremy Longshore \u003Cjeremy@intentsolutions.io>\ntags: [saas, langchain, langgraph, python, langchain-1.0, statgraph]\ncompatible-with: claude-code, codex\n---\n\n# LangChain LangGraph Basics (Python)\n\n## Overview\n\nA conditional edge whose router returns a string that is not in `path_map` halts\nthe graph without reaching `END`. No exception. No log line. The invocation just\nreturns whatever state existed at the halt point — pain-catalog entry P56, and\nthe single most common reason a newly wired `StateGraph` \"almost works.\" The\nsibling pain: `Command(update={\"messages\": [msg]})` wipes the prior message\nhistory because `messages` was declared as a plain `list[AnyMessage]` instead of\n`Annotated[list[AnyMessage], add_messages]` — the reducer is what turns `update`\ninto \"append\" instead of \"replace\" (P18).\n\nTwo more gotchas this skill defuses:\n\n- P55 — `GraphRecursionError: Recursion limit of 25 reached` fires on graphs\n  that never loop, because `recursion_limit` counts **supersteps** (one step\n  per synchronous batch of node executions), not loop iterations. A planner\n  + executor + validator + summarizer can hit 25 without any cycle.\n- P20 — Upgrading `langgraph` silently reads old `PostgresSaver` checkpoints\n  as empty state. Checkpoint schemas evolve; `PostgresSaver.setup()` must be\n  rerun after every version bump before production traffic.\n\nThis skill walks through a minimal `StateGraph` end to end: a `TypedDict` state\nwith reducers on every list field, node functions that return partial-state\ndicts, edges and defensive conditional edges with `END` as a fallback in\n`path_map`, compilation with a checkpointer, `recursion_limit` sizing, and\ninvocation with an explicit `thread_id`. Pin: `langgraph 1.0.x`,\n`langchain-core 1.0.x`. Pain-catalog anchors: P16, P18, P20, P55, P56.\n\n## Prerequisites\n\n- Python 3.10+\n- `pip install langgraph>=1.0,\u003C2.0 langchain-core>=1.0,\u003C2.0`\n- A chat model (see `langchain-model-inference`), or a pure-logic graph with no LLM\n- For persistence beyond a single process: `pip install langgraph-checkpoint-postgres` and a Postgres 14+ instance\n\n## Instructions\n\n### Step 1 — Define state as a `TypedDict` with reducers on list fields\n\nEvery list-shaped field in state needs a reducer. Without one, `Command(update=...)`\nand node returns *replace* the field. The message-history reducer lives in\n`langgraph.graph.message`:\n\n```python\nfrom typing import Annotated, TypedDict\nfrom langchain_core.messages import AnyMessage\nfrom langgraph.graph.message import add_messages\nimport operator\n\nclass AgentState(TypedDict):\n    # Reducer \"add_messages\" appends + dedupes by message id (P18)\n    messages: Annotated[list[AnyMessage], add_messages]\n\n    # Plain list field also needs a reducer — use operator.add to concat\n    scratchpad: Annotated[list[str], operator.add]\n\n    # Scalars don't need a reducer; update replaces them\n    step_count: int\n    done: bool\n```\n\nIf you forget the reducer on `messages`, a resume with\n`Command(update={\"messages\": [new_msg]})` will overwrite the entire prior\nhistory. Validate reducers are in place with `graph.get_graph().draw_mermaid()` —\nannotated fields render with their reducer name.\n\nSee [State Reducers](references\u002Fstate-reducers.md) for the built-in list\n(`add_messages`, `operator.add`, `max`, `min`) and how to write a custom merger\nfor non-trivial merge logic.\n\n### Step 2 — Write nodes as functions that return partial-state dicts\n\nA node takes the full state and returns only the keys it wants to update. The\nreducer handles merge:\n\n```python\ndef plan(state: AgentState) -> dict:\n    # Returning a dict means \"update these fields\"\n    return {\n        \"messages\": [(\"assistant\", \"Plan: step 1, step 2, step 3\")],\n        \"scratchpad\": [\"planned_at_step_1\"],\n        \"step_count\": state[\"step_count\"] + 1,\n    }\n\ndef execute(state: AgentState) -> dict:\n    return {\n        \"messages\": [(\"assistant\", f\"Executed {state['step_count']} steps\")],\n        \"done\": state[\"step_count\"] >= 3,\n    }\n```\n\nNodes must be deterministic on their inputs — LangGraph re-runs them during\ntime-travel replay, and a side-effecting node (DB write without idempotency key)\nwill double-fire. Push side effects to the checkpointer boundary or tool calls.\n\n### Step 3 — Wire edges and conditional edges defensively\n\n```python\nfrom typing import Literal\nfrom langgraph.graph import StateGraph, START, END\n\n# Router MUST return a value in the path_map keyset (P56)\ndef should_continue(state: AgentState) -> Literal[\"execute\", \"end\"]:\n    if state[\"done\"] or state[\"step_count\"] >= 10:\n        return \"end\"\n    return \"execute\"\n\nbuilder = StateGraph(AgentState)\nbuilder.add_node(\"plan\", plan)\nbuilder.add_node(\"execute\", execute)\n\nbuilder.add_edge(START, \"plan\")\n\n# path_map ALWAYS includes END as a fallback — if the router returns anything\n# else, the graph reaches END instead of halting silently (P56)\nbuilder.add_conditional_edges(\n    \"plan\",\n    should_continue,\n    path_map={\"execute\": \"execute\", \"end\": END},\n)\nbuilder.add_edge(\"execute\", \"plan\")  # loop back to plan\n```\n\nThe `Literal` return annotation on `should_continue` is a static guard — mypy\ncatches typos before runtime. `path_map={\"execute\": \"execute\", \"end\": END}`\nis the spelled-out form; the compact form `path_map=[\"execute\", END]` also works\nwhen router return values match node names directly.\n\nSee [Conditional Edges](references\u002Fconditional-edges.md) for all four\n`add_conditional_edges` signatures, the `path` vs `path_map` distinction, and\na pytest pattern that asserts every router return value hits a known route.\n\n### Step 4 — Compile with a checkpointer\n\n```python\nfrom langgraph.checkpoint.memory import MemorySaver\n\n# MemorySaver is in-process — use PostgresSaver in production (P20)\ncheckpointer = MemorySaver()\ngraph = builder.compile(checkpointer=checkpointer)\n```\n\nFor production, swap to `langgraph.checkpoint.postgres.PostgresSaver`. After\nevery `langgraph` version bump, run `PostgresSaver.setup()` in staging before\nprod traffic — the schema evolves and old rows are silently read as empty state.\n\n### Step 5 — Pick `recursion_limit` for the graph's superstep count\n\n`recursion_limit` defaults to **25**. It is not a loop counter; it counts\n**total supersteps**, and a superstep is one synchronous round of node\nexecutions (parallel branches in the same step count as one). Typical shapes:\n\n| Graph shape | Supersteps per run | Suggested `recursion_limit` |\n|---|---|---|\n| Simple ReAct agent (plan → tool → observe → done) | 6-12 | 15 |\n| Planner + executor + validator | 12-25 | 30 |\n| Deep agent with sub-plans, reflection, branch merge | 30-60 | 75 |\n| Fan-out with N parallel branches that re-join | N + merge steps | 2 × max depth |\n\n```python\nconfig = {\n    \"configurable\": {\"thread_id\": \"user-42\"},  # required for checkpointing (P16)\n    \"recursion_limit\": 30,\n}\nresult = graph.invoke({\"messages\": [], \"scratchpad\": [], \"step_count\": 0, \"done\": False}, config)\n```\n\nIf you hit `GraphRecursionError` on a graph that clearly isn't looping (P55),\nadd `print(state[\"step_count\"])` at the entry of each node to see the actual\nsuperstep count, then either raise the limit or restructure with a subgraph\nso each subgraph gets its own budget.\n\nSee [Recursion Limits](references\u002Frecursion-limits.md) for the full derivation\nand a diagnostic script that traces superstep count at runtime.\n\n### Step 6 — Invoke with `thread_id` in `config[\"configurable\"]`\n\nEvery invocation against a checkpointer-backed graph needs a `thread_id` in\n`config[\"configurable\"]`. Without it, each call gets a fresh state with no\nwarning (P16). Enforce it at your application boundary:\n\n```python\ndef run_agent(user_id: str, user_message: str) -> dict:\n    config = {\n        \"configurable\": {\"thread_id\": user_id},\n        \"recursion_limit\": 30,\n    }\n    assert config[\"configurable\"].get(\"thread_id\"), \"thread_id required\"\n    return graph.invoke(\n        {\"messages\": [(\"user\", user_message)], \"scratchpad\": [], \"step_count\": 0, \"done\": False},\n        config,\n    )\n```\n\nSee [First Graph Walkthrough](references\u002Ffirst-graph-walkthrough.md) for a\nline-by-line annotation of a minimal 3-node graph that demonstrates typed\nstate, a reducer, and a conditional edge to `END`.\n\n## Decision Tree\n\n```\nIs your field a list you want to append?\n  -> Annotate with add_messages (for messages) or operator.add (for plain lists)\n\nIs your router adding a new output string?\n  -> Add that string to path_map BEFORE deploying; include END as a fallback\n\nHitting GraphRecursionError on a non-looping graph?\n  -> supersteps != iterations; raise recursion_limit to 50 or split into subgraphs\n\nUpgraded langgraph minor version?\n  -> Re-run PostgresSaver.setup() in staging before routing prod traffic\n\nMulti-turn agent forgets between calls?\n  -> thread_id missing from config[\"configurable\"] — enforce at boundary\n```\n\n## Output\n\n- `TypedDict` state with reducer annotations on every list field\n- Node functions returning partial-state dicts, free of hidden side effects\n- Conditional edges with `Literal`-typed routers and `END` in every `path_map`\n- Compiled graph with a checkpointer matched to the deployment shape\n- `recursion_limit` sized from the superstep count table, not the default 25\n- Invocations with explicit `thread_id` validated at the app boundary\n\n## Error Handling\n\n| Error | Cause | Fix |\n|-------|-------|-----|\n| `GraphRecursionError: Recursion limit of 25 reached` | Supersteps counter, not loops (P55) | Raise `recursion_limit` or split into subgraphs; add per-node logging to count actual steps |\n| Graph halts without reaching `END`, no error | Router returned a value not in `path_map` (P56) | Type router as `Literal[...]`; include `END` as a default key in `path_map` |\n| `Command(update={\"messages\": [msg]})` wipes history | Missing reducer on list field (P18) | Annotate as `Annotated[list[AnyMessage], add_messages]` |\n| Multi-turn memory resets between calls, no warning | Missing `thread_id` in config (P16) | Assert `config[\"configurable\"][\"thread_id\"]` at app boundary |\n| Old checkpoints read as empty state after upgrade | Schema change; `PostgresSaver` doesn't auto-migrate (P20) | Run `PostgresSaver.setup()` in staging after every `langgraph` bump |\n| `TypeError: Object of type datetime is not JSON serializable` at interrupt | Non-primitive in state (P17) | Keep state primitives-only; serialize complex types to ISO strings |\n| Node runs twice during replay | Time-travel re-executes deterministic nodes | Push side effects to tools or the checkpointer write boundary |\n\n## Examples\n\n### Building a minimal linear graph (no loop)\n\nThree nodes (`plan` → `execute` → `summarize`), no conditionals, one reducer on\n`messages`. Runs in 4 supersteps (START counts as one). Safe at default\n`recursion_limit=25`, but set it to 10 explicitly so readers see the budget.\n\nSee [First Graph Walkthrough](references\u002Ffirst-graph-walkthrough.md) for the\nline-by-line annotation and the `graph.get_graph().draw_mermaid()` output.\n\n### Adding a conditional loop with a bounded retry budget\n\nA validator node that either completes (`\"end\"` → `END`) or retries\n(`\"retry\"` → back to executor), bounded by `step_count >= 3`. The router is\n`Literal[\"retry\", \"end\"]` and `path_map` maps both. Caps at 7 supersteps, so\n`recursion_limit=15` is plenty of headroom.\n\nSee [Conditional Edges](references\u002Fconditional-edges.md) for the full example\nand the pytest that iterates every `Literal` branch.\n\n### Diagnosing a mystery `GraphRecursionError`\n\nA planner that fans out to 4 parallel executors, then a validator, then a\nsummarizer. Looks linear in the mermaid diagram, hits\n`GraphRecursionError: Recursion limit of 25 reached` on 10% of runs. Cause:\neach parallel executor counts as its own superstep branch when the merge node\nis conditional. Fix: raise to 50 or wrap the fan-out in a subgraph.\n\nSee [Recursion Limits](references\u002Frecursion-limits.md) for the diagnostic\nscript and the subgraph refactor.\n\n## Resources\n\n- [LangGraph: Low-level concepts (StateGraph, reducers, nodes, edges)](https:\u002F\u002Flangchain-ai.github.io\u002Flanggraph\u002Fconcepts\u002Flow_level\u002F)\n- [LangGraph: Persistence and checkpointing](https:\u002F\u002Flangchain-ai.github.io\u002Flanggraph\u002Fconcepts\u002Fpersistence\u002F)\n- [LangGraph: `add_messages` reducer](https:\u002F\u002Flangchain-ai.github.io\u002Flanggraph\u002Freference\u002Fgraphs\u002F#langgraph.graph.message.add_messages)\n- [LangGraph: `add_conditional_edges` API](https:\u002F\u002Flangchain-ai.github.io\u002Flanggraph\u002Freference\u002Fgraphs\u002F#langgraph.graph.state.StateGraph.add_conditional_edges)\n- [LangGraph: Recursion limit and supersteps](https:\u002F\u002Flangchain-ai.github.io\u002Flanggraph\u002Fhow-tos\u002Frecursion-limit\u002F)\n- [LangChain 1.0 release notes](https:\u002F\u002Fblog.langchain.com\u002Flangchain-langgraph-1dot0\u002F)\n- Pack pain catalog: `docs\u002Fpain-catalog.md` (entries P16, P17, P18, P20, P55, P56)\n","# LangChain LangGraph Basics (Python)\n\n## Overview\n\nA conditional edge whose router returns a string that is not in `path_map` halts\nthe graph without reaching `END`. No exception. No log line. The invocation just\nreturns whatever state existed at the halt point — pain-catalog entry P56, and\nthe single most common reason a newly wired `StateGraph` \"almost works.\" The\nsibling pain: `Command(update={\"messages\": [msg]})` wipes the prior message\nhistory because `messages` was declared as a plain `list[AnyMessage]` instead of\n`Annotated[list[AnyMessage], add_messages]` — the reducer is what turns `update`\ninto \"append\" instead of \"replace\" (P18).\n\nTwo more gotchas this skill defuses:\n\n- P55 — `GraphRecursionError: Recursion limit of 25 reached` fires on graphs\n  that never loop, because `recursion_limit` counts **supersteps** (one step\n  per synchronous batch of node executions), not loop iterations. A planner\n  + executor + validator + summarizer can hit 25 without any cycle.\n- P20 — Upgrading `langgraph` silently reads old `PostgresSaver` checkpoints\n  as empty state. Checkpoint schemas evolve; `PostgresSaver.setup()` must be\n  rerun after every version bump before production traffic.\n\nThis skill walks through a minimal `StateGraph` end to end: a `TypedDict` state\nwith reducers on every list field, node functions that return partial-state\ndicts, edges and defensive conditional edges with `END` as a fallback in\n`path_map`, compilation with a checkpointer, `recursion_limit` sizing, and\ninvocation with an explicit `thread_id`. Pin: `langgraph 1.0.x`,\n`langchain-core 1.0.x`. Pain-catalog anchors: P16, P18, P20, P55, P56.\n\n## Prerequisites\n\n- Python 3.10+\n- `pip install langgraph>=1.0,\u003C2.0 langchain-core>=1.0,\u003C2.0`\n- A chat model (see `langchain-model-inference`), or a pure-logic graph with no LLM\n- For persistence beyond a single process: `pip install langgraph-checkpoint-postgres` and a Postgres 14+ instance\n\n## Instructions\n\n### Step 1 — Define state as a `TypedDict` with reducers on list fields\n\nEvery list-shaped field in state needs a reducer. Without one, `Command(update=...)`\nand node returns *replace* the field. The message-history reducer lives in\n`langgraph.graph.message`:\n\n```python\nfrom typing import Annotated, TypedDict\nfrom langchain_core.messages import AnyMessage\nfrom langgraph.graph.message import add_messages\nimport operator\n\nclass AgentState(TypedDict):\n    # Reducer \"add_messages\" appends + dedupes by message id (P18)\n    messages: Annotated[list[AnyMessage], add_messages]\n\n    # Plain list field also needs a reducer — use operator.add to concat\n    scratchpad: Annotated[list[str], operator.add]\n\n    # Scalars don't need a reducer; update replaces them\n    step_count: int\n    done: bool\n```\n\nIf you forget the reducer on `messages`, a resume with\n`Command(update={\"messages\": [new_msg]})` will overwrite the entire prior\nhistory. Validate reducers are in place with `graph.get_graph().draw_mermaid()` —\nannotated fields render with their reducer name.\n\nSee [State Reducers](references\u002Fstate-reducers.md) for the built-in list\n(`add_messages`, `operator.add`, `max`, `min`) and how to write a custom merger\nfor non-trivial merge logic.\n\n### Step 2 — Write nodes as functions that return partial-state dicts\n\nA node takes the full state and returns only the keys it wants to update. The\nreducer handles merge:\n\n```python\ndef plan(state: AgentState) -> dict:\n    # Returning a dict means \"update these fields\"\n    return {\n        \"messages\": [(\"assistant\", \"Plan: step 1, step 2, step 3\")],\n        \"scratchpad\": [\"planned_at_step_1\"],\n        \"step_count\": state[\"step_count\"] + 1,\n    }\n\ndef execute(state: AgentState) -> dict:\n    return {\n        \"messages\": [(\"assistant\", f\"Executed {state['step_count']} steps\")],\n        \"done\": state[\"step_count\"] >= 3,\n    }\n```\n\nNodes must be deterministic on their inputs — LangGraph re-runs them during\ntime-travel replay, and a side-effecting node (DB write without idempotency key)\nwill double-fire. Push side effects to the checkpointer boundary or tool calls.\n\n### Step 3 — Wire edges and conditional edges defensively\n\n```python\nfrom typing import Literal\nfrom langgraph.graph import StateGraph, START, END\n\n# Router MUST return a value in the path_map keyset (P56)\ndef should_continue(state: AgentState) -> Literal[\"execute\", \"end\"]:\n    if state[\"done\"] or state[\"step_count\"] >= 10:\n        return \"end\"\n    return \"execute\"\n\nbuilder = StateGraph(AgentState)\nbuilder.add_node(\"plan\", plan)\nbuilder.add_node(\"execute\", execute)\n\nbuilder.add_edge(START, \"plan\")\n\n# path_map ALWAYS includes END as a fallback — if the router returns anything\n# else, the graph reaches END instead of halting silently (P56)\nbuilder.add_conditional_edges(\n    \"plan\",\n    should_continue,\n    path_map={\"execute\": \"execute\", \"end\": END},\n)\nbuilder.add_edge(\"execute\", \"plan\")  # loop back to plan\n```\n\nThe `Literal` return annotation on `should_continue` is a static guard — mypy\ncatches typos before runtime. `path_map={\"execute\": \"execute\", \"end\": END}`\nis the spelled-out form; the compact form `path_map=[\"execute\", END]` also works\nwhen router return values match node names directly.\n\nSee [Conditional Edges](references\u002Fconditional-edges.md) for all four\n`add_conditional_edges` signatures, the `path` vs `path_map` distinction, and\na pytest pattern that asserts every router return value hits a known route.\n\n### Step 4 — Compile with a checkpointer\n\n```python\nfrom langgraph.checkpoint.memory import MemorySaver\n\n# MemorySaver is in-process — use PostgresSaver in production (P20)\ncheckpointer = MemorySaver()\ngraph = builder.compile(checkpointer=checkpointer)\n```\n\nFor production, swap to `langgraph.checkpoint.postgres.PostgresSaver`. After\nevery `langgraph` version bump, run `PostgresSaver.setup()` in staging before\nprod traffic — the schema evolves and old rows are silently read as empty state.\n\n### Step 5 — Pick `recursion_limit` for the graph's superstep count\n\n`recursion_limit` defaults to **25**. It is not a loop counter; it counts\n**total supersteps**, and a superstep is one synchronous round of node\nexecutions (parallel branches in the same step count as one). Typical shapes:\n\n| Graph shape | Supersteps per run | Suggested `recursion_limit` |\n|---|---|---|\n| Simple ReAct agent (plan → tool → observe → done) | 6-12 | 15 |\n| Planner + executor + validator | 12-25 | 30 |\n| Deep agent with sub-plans, reflection, branch merge | 30-60 | 75 |\n| Fan-out with N parallel branches that re-join | N + merge steps | 2 × max depth |\n\n```python\nconfig = {\n    \"configurable\": {\"thread_id\": \"user-42\"},  # required for checkpointing (P16)\n    \"recursion_limit\": 30,\n}\nresult = graph.invoke({\"messages\": [], \"scratchpad\": [], \"step_count\": 0, \"done\": False}, config)\n```\n\nIf you hit `GraphRecursionError` on a graph that clearly isn't looping (P55),\nadd `print(state[\"step_count\"])` at the entry of each node to see the actual\nsuperstep count, then either raise the limit or restructure with a subgraph\nso each subgraph gets its own budget.\n\nSee [Recursion Limits](references\u002Frecursion-limits.md) for the full derivation\nand a diagnostic script that traces superstep count at runtime.\n\n### Step 6 — Invoke with `thread_id` in `config[\"configurable\"]`\n\nEvery invocation against a checkpointer-backed graph needs a `thread_id` in\n`config[\"configurable\"]`. Without it, each call gets a fresh state with no\nwarning (P16). Enforce it at your application boundary:\n\n```python\ndef run_agent(user_id: str, user_message: str) -> dict:\n    config = {\n        \"configurable\": {\"thread_id\": user_id},\n        \"recursion_limit\": 30,\n    }\n    assert config[\"configurable\"].get(\"thread_id\"), \"thread_id required\"\n    return graph.invoke(\n        {\"messages\": [(\"user\", user_message)], \"scratchpad\": [], \"step_count\": 0, \"done\": False},\n        config,\n    )\n```\n\nSee [First Graph Walkthrough](references\u002Ffirst-graph-walkthrough.md) for a\nline-by-line annotation of a minimal 3-node graph that demonstrates typed\nstate, a reducer, and a conditional edge to `END`.\n\n## Decision Tree\n\n```\nIs your field a list you want to append?\n  -> Annotate with add_messages (for messages) or operator.add (for plain lists)\n\nIs your router adding a new output string?\n  -> Add that string to path_map BEFORE deploying; include END as a fallback\n\nHitting GraphRecursionError on a non-looping graph?\n  -> supersteps != iterations; raise recursion_limit to 50 or split into subgraphs\n\nUpgraded langgraph minor version?\n  -> Re-run PostgresSaver.setup() in staging before routing prod traffic\n\nMulti-turn agent forgets between calls?\n  -> thread_id missing from config[\"configurable\"] — enforce at boundary\n```\n\n## Output\n\n- `TypedDict` state with reducer annotations on every list field\n- Node functions returning partial-state dicts, free of hidden side effects\n- Conditional edges with `Literal`-typed routers and `END` in every `path_map`\n- Compiled graph with a checkpointer matched to the deployment shape\n- `recursion_limit` sized from the superstep count table, not the default 25\n- Invocations with explicit `thread_id` validated at the app boundary\n\n## Error Handling\n\n| Error | Cause | Fix |\n|-------|-------|-----|\n| `GraphRecursionError: Recursion limit of 25 reached` | Supersteps counter, not loops (P55) | Raise `recursion_limit` or split into subgraphs; add per-node logging to count actual steps |\n| Graph halts without reaching `END`, no error | Router returned a value not in `path_map` (P56) | Type router as `Literal[...]`; include `END` as a default key in `path_map` |\n| `Command(update={\"messages\": [msg]})` wipes history | Missing reducer on list field (P18) | Annotate as `Annotated[list[AnyMessage], add_messages]` |\n| Multi-turn memory resets between calls, no warning | Missing `thread_id` in config (P16) | Assert `config[\"configurable\"][\"thread_id\"]` at app boundary |\n| Old checkpoints read as empty state after upgrade | Schema change; `PostgresSaver` doesn't auto-migrate (P20) | Run `PostgresSaver.setup()` in staging after every `langgraph` bump |\n| `TypeError: Object of type datetime is not JSON serializable` at interrupt | Non-primitive in state (P17) | Keep state primitives-only; serialize complex types to ISO strings |\n| Node runs twice during replay | Time-travel re-executes deterministic nodes | Push side effects to tools or the checkpointer write boundary |\n\n## Examples\n\n### Building a minimal linear graph (no loop)\n\nThree nodes (`plan` → `execute` → `summarize`), no conditionals, one reducer on\n`messages`. Runs in 4 supersteps (START counts as one). Safe at default\n`recursion_limit=25`, but set it to 10 explicitly so readers see the budget.\n\nSee [First Graph Walkthrough](references\u002Ffirst-graph-walkthrough.md) for the\nline-by-line annotation and the `graph.get_graph().draw_mermaid()` output.\n\n### Adding a conditional loop with a bounded retry budget\n\nA validator node that either completes (`\"end\"` → `END`) or retries\n(`\"retry\"` → back to executor), bounded by `step_count >= 3`. The router is\n`Literal[\"retry\", \"end\"]` and `path_map` maps both. Caps at 7 supersteps, so\n`recursion_limit=15` is plenty of headroom.\n\nSee [Conditional Edges](references\u002Fconditional-edges.md) for the full example\nand the pytest that iterates every `Literal` branch.\n\n### Diagnosing a mystery `GraphRecursionError`\n\nA planner that fans out to 4 parallel executors, then a validator, then a\nsummarizer. Looks linear in the mermaid diagram, hits\n`GraphRecursionError: Recursion limit of 25 reached` on 10% of runs. Cause:\neach parallel executor counts as its own superstep branch when the merge node\nis conditional. Fix: raise to 50 or wrap the fan-out in a subgraph.\n\nSee [Recursion Limits](references\u002Frecursion-limits.md) for the diagnostic\nscript and the subgraph refactor.\n\n## Resources\n\n- [LangGraph: Low-level concepts (StateGraph, reducers, nodes, edges)](https:\u002F\u002Flangchain-ai.github.io\u002Flanggraph\u002Fconcepts\u002Flow_level\u002F)\n- [LangGraph: Persistence and checkpointing](https:\u002F\u002Flangchain-ai.github.io\u002Flanggraph\u002Fconcepts\u002Fpersistence\u002F)\n- [LangGraph: `add_messages` reducer](https:\u002F\u002Flangchain-ai.github.io\u002Flanggraph\u002Freference\u002Fgraphs\u002F#langgraph.graph.message.add_messages)\n- [LangGraph: `add_conditional_edges` API](https:\u002F\u002Flangchain-ai.github.io\u002Flanggraph\u002Freference\u002Fgraphs\u002F#langgraph.graph.state.StateGraph.add_conditional_edges)\n- [LangGraph: Recursion limit and supersteps](https:\u002F\u002Flangchain-ai.github.io\u002Flanggraph\u002Fhow-tos\u002Frecursion-limit\u002F)\n- [LangChain 1.0 release notes](https:\u002F\u002Fblog.langchain.com\u002Flangchain-langgraph-1dot0\u002F)\n- Pack pain catalog: `docs\u002Fpain-catalog.md` (entries P16, P17, P18, P20, P55, P56)\n",{"name":5,"tags":24,"author":31,"license":15,"version":32,"description":33,"allowed-tools":34,"compatible-with":35},[25,26,27,28,29,30],"saas","langchain","langgraph","python","langchain-1.0","statgraph","Jeremy Longshore \u003Cjeremy@intentsolutions.io>","2.0.0","Build a correct LangGraph 1.0 StateGraph — typed TypedDict state with reducers,\nnodes, edges, compile, and recursion budgets — without hitting the silent-termination\nand state-replacement traps. Use when writing your first LangGraph StateGraph,\ndiagnosing why a graph halted without reaching END, or picking recursion_limit.\nTrigger with \"langgraph statgraph\", \"langgraph basics\", \"GraphRecursionError\",\n\"langgraph conditional edges\".\n","Read, Write, Edit, Bash(python:*)","claude-code, codex","main","99825ad3f3bcc6597ddcc7294a14e6e922f2b67b","skills\u002Fsaas-packs--langchain-py-pack--langchain-langgraph-basics",0,"https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills","https:\u002F\u002Fgithub.com\u002Fjukeyman","https:\u002F\u002FRJBUSINESSSOLUTIONS.ORG","Credit and Finance Expert | Developer\r\n\r\nI'm Rick Jefferson, a seasoned credit and finance expert with over a decade of experience in financial literacy,","2026-07-13 07:03:29",{"source":8,"skillName":5,"commands":46,"prompt":56,"zipAvailable":57},[47,50,53],{"tool":48,"command":49},"npx","npx skills add jukeyman\u002Fjukeyman-skills --skill langchain-langgraph-basics",{"tool":51,"command":52},"bunx","bunx skills add jukeyman\u002Fjukeyman-skills --skill langchain-langgraph-basics",{"tool":54,"command":55},"pnpm","pnpm dlx skills add jukeyman\u002Fjukeyman-skills --skill langchain-langgraph-basics","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fsaas-packs--langchain-py-pack--langchain-langgraph-basics\u002FSKILL.md",true,[],[60,67,74,81,88,96],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M79ANS2SM329NEP5ZCX106RR","zustand-store-creator","Create zustand store creator operations. Auto-activating skill for Frontend Development.\nTriggers on: zustand store creator, zustand store creator\nPart of the Frontend Development skill category. Use when working with zustand store creator functionality. Trigger with phrases like \"zustand store creator\", \"zustand creator\", \"zustand\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzustand-store-creator\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M79AMZKP4YDEZ7EHG1Y7PP74","zero-trust-config-helper","Configure with zero trust config helper operations. Auto-activating skill for Security Advanced.\nTriggers on: zero trust config helper, zero trust config helper\nPart of the Security Advanced skill category. Use when configuring systems or services. Trigger with phrases like \"zero trust config helper\", \"zero helper\", \"zero\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzero-trust-config-helper\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M79AMJSBCEJQNBTYNAHYN5HM","zapier-integration-helper","Assist with zapier integration helper operations. Auto-activating skill for Business Automation.\nTriggers on: zapier integration helper, zapier integration helper\nPart of the Business Automation skill category. Use when working with APIs or building integrations. Trigger with phrases like \"zapier integration helper\", \"zapier helper\", \"zapier\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzapier-integration-helper\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M79AHJZGVMARS13VFQYRR1MP","yaml-config-validator","Validate yaml config validator operations. Auto-activating skill for DevOps Basics.\nTriggers on: yaml config validator, yaml config validator\nPart of the DevOps Basics skill category. Use when configuring systems or services. Trigger with phrases like \"yaml config validator\", \"yaml validator\", \"yaml\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fyaml-config-validator\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":92,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":19},"01M79AHGDZRN0020RDQSQDPAM8","xvary-stock-research","Thesis-driven equity analysis from public SEC EDGAR and market data; \u002Fanalyze, \u002Fscore, \u002Fcompare workflows with bundled Python tools (Claude Code, Cursor, Codex).","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxvary-stock-research\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxvary-stock-research\u002FSKILL.md",[],[],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":19},"01M79AHCYJ9FV9RMHQ24HDRN33","xss-vulnerability-scanner","Scan xss vulnerability scanner operations. Auto-activating skill for Security Fundamentals.\nTriggers on: xss vulnerability scanner, xss vulnerability scanner\nPart of the Security Fundamentals skill category. Use when working with xss vulnerability scanner functionality. Trigger with phrases like \"xss vulnerability scanner\", \"xss scanner\", \"xss\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxss-vulnerability-scanner\u002FSKILL.md",[],[]]