[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M792C3FAH01MTAFZ3JRWEPXE":3,"skill-same:01M792C3FAH01MTAFZ3JRWEPXE":61},{"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":38,"commitSha":39,"skillDirectory":40,"forksCount":41,"repositoryHtmlUrl":42,"repositoryHomepageUrl":6,"ownerHtmlUrl":43,"ownerBlogUrl":44,"ownerDescription":45,"updatedAt":46,"install":47,"resources":60},"01M792C3FAH01MTAFZ3JRWEPXE","langchain-langgraph-human-in-loop",null,"Build LangGraph 1.0 human-in-the-loop approval flows with `interrupt_before` \u002F\n`interrupt_after` and `Command(resume=...)` — JSON-serializable state, clean\nresume semantics, and UI wiring for approval decisions. Use when adding an\napproval gate before an expensive tool call, wiring a Slack\u002Fweb UI for agent\napprovals, or debugging a graph that crashes on interrupt.\nTrigger with \"langgraph human in loop\", \"langgraph interrupt_before\",\n\"langgraph approval flow\", \"Command resume\", \"langgraph HITL\".","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-human-in-loop\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: langchain-langgraph-human-in-loop\ndescription: |\n  Build LangGraph 1.0 human-in-the-loop approval flows with `interrupt_before` \u002F\n  `interrupt_after` and `Command(resume=...)` — JSON-serializable state, clean\n  resume semantics, and UI wiring for approval decisions. Use when adding an\n  approval gate before an expensive tool call, wiring a Slack\u002Fweb UI for agent\n  approvals, or debugging a graph that crashes on interrupt.\n  Trigger with \"langgraph human in loop\", \"langgraph interrupt_before\",\n  \"langgraph approval flow\", \"Command resume\", \"langgraph HITL\".\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, human-in-loop, approval, interrupts]\ncompatible-with: claude-code, codex\n---\n\n# LangChain LangGraph Human-in-the-Loop (Python)\n\n## Overview\n\nA team adds `interrupt_before=[\"send_email\"]` to require a human approval\nbefore the email goes out. First integration test crashes at the interrupt\nboundary with:\n\n```\nTypeError: Object of type datetime is not JSON serializable\n```\n\nThe culprit is two nodes upstream: a `classify` node stashed\n`\"received_at\": datetime.utcnow()` into state. Every node-level unit test\npassed because node completion does not serialize state — only the\ncheckpointer does, and only at supersteps that include an interrupt. The\nfailure is invisible until interrupt time (P17).\n\nA week later the resume path ships. The human reviews the draft, clicks\n\"approve with edits,\" and the backend runs:\n\n```python\ngraph.invoke(Command(update={\"messages\": [corrected_msg]}, resume=\"approved\"), config)\n```\n\nThe prior 47 messages vanish. `messages` was typed as plain\n`list[AnyMessage]` with no reducer, so `update` replaces the field instead of\nappending (P18).\n\nThis skill covers: three interrupt styles (`interrupt_before`,\n`interrupt_after`, inline `interrupt()`), the JSON-only state invariant with\na pre-interrupt scanner, the `Command(resume=...)` \u002F\n`Command(update=..., resume=...)` contract, an approval UI wire format\n(GET pending \u002F POST decision with optimistic concurrency), safe-cancellation\nrouting to `END`, and the tradeoff between native interrupts and a separate\napproval service. Pin: `langgraph 1.0.x`, `langgraph-checkpoint 2.0.x`.\nPain-catalog anchors: **P17**, **P18** (adjacent: P16, P20).\n\n## Prerequisites\n\n- Python 3.10+\n- `langgraph >= 1.0, \u003C 2.0`\n- A checkpointer: `MemorySaver` (dev), `PostgresSaver` (prod), or `SqliteSaver` (single-box)\n- A `thread_id` contract at the app boundary (see `langchain-langgraph-checkpointing`)\n- Familiarity with `langchain-langgraph-basics` — nodes, edges, `TypedDict` state with reducers\n\n## Instructions\n\n### Step 1 — Choose the interrupt style\n\nLangGraph 1.0 exposes three interrupt mechanisms. They are not interchangeable.\n\n| Style | Syntax | Use when |\n|-------|--------|----------|\n| `interrupt_before=[node]` | `compile(interrupt_before=[\"send_email\"])` | Review inputs before an irreversible tool. Graph pauses *before* node runs. State shown is the input. |\n| `interrupt_after=[node]` | `compile(interrupt_after=[\"draft_email\"])` | Review output of a node (e.g., an LLM draft). Graph pauses *after* node completes. |\n| Inline `interrupt()` | Inside a node: `decision = interrupt({\"kind\": \"...\"})` | Structured prompt mid-node with custom payload. Most flexible; lives in node code. |\n\nRule of thumb: prefer `interrupt_before` for hard gates (tool must not run\nwithout approval). Use `interrupt_after` for review loops (draft → approve →\nsend). Use inline `interrupt()` when the prompt varies on intermediate\ncomputation.\n\nTypical interrupt round-trip latency in production is **50-300 ms** from\npause to checkpoint write (local Postgres) plus UI time; budget **1-5 s**\ntotal for a Slack-based approval. Checkpoint row sizes average **2-20 KB** on\nsmall graphs and cap at **~1 MB** on `PostgresSaver` before historical\ncheckpoints need pruning.\n\nSee [Interrupt Decision Tree](references\u002Finterrupt-decision-tree.md) for full\ncriteria, multiple-interrupt-per-graph patterns, and the interrupt-vs-tool\ncomparison.\n\n### Step 2 — Enforce the JSON-serializable state invariant (P17)\n\nCheckpointers serialize state to JSON on every superstep. Any non-JSON type\nraises `TypeError` at the interrupt boundary — not at the offending node.\nCanonical offenders:\n\n| Type | Fix |\n|------|-----|\n| `datetime` \u002F `date` | `dt.isoformat()` — ISO 8601 string |\n| `bytes` | `base64.b64encode(b).decode()` |\n| `set` | `sorted(s)` |\n| Pydantic `BaseModel` with non-primitive fields | `.model_dump(mode=\"json\")` |\n| Custom classes | `dataclasses.asdict(obj)` or `vars(obj)` |\n| `numpy.ndarray` | `.tolist()` |\n| `decimal.Decimal` | `str(d)` or `float(d)` (lossy) |\n| `float(\"nan\")` \u002F `float(\"inf\")` | `None` (JSON forbids them; some savers crash on `allow_nan=False`) |\n\nShip a pre-interrupt scanner in dev and CI:\n\n```python\nimport json\nfrom typing import Any\n\nclass NonSerializableStateError(TypeError):\n    \"\"\"Raised when state contains values the checkpointer cannot serialize.\"\"\"\n\ndef assert_state_is_json_serializable(state: dict[str, Any], *, path: str = \"state\") -> None:\n    \"\"\"Walk state depth-first and raise a typed error naming the offending key path.\"\"\"\n    _walk(state, path)\n\ndef _walk(v: Any, path: str) -> None:\n    if v is None or isinstance(v, (bool, int, float, str)):\n        return\n    if isinstance(v, list):\n        for i, item in enumerate(v):\n            _walk(item, f\"{path}[{i}]\")\n        return\n    if isinstance(v, dict):\n        for k, val in v.items():\n            _walk(val, f\"{path}.{k}\")\n        return\n    raise NonSerializableStateError(\n        f\"{path} is {type(v).__name__}, not JSON-serializable. \"\n        f\"Convert at node boundary.\"\n    )\n```\n\nCall `assert_state_is_json_serializable(state)` at the end of every node\npreceding an interrupt-flagged node, or attach as LangGraph middleware. In\nCI, run the full graph to interrupt against a fixture that exercises every\nbranch — the only way to catch P17 before prod.\n\nSee [State Serialization for Interrupts](references\u002Fstate-serialization-for-interrupts.md)\nfor the full forbidden-types list, the Pydantic-in-state pattern, and the\nintegration-test harness.\n\n### Step 3 — The resume contract\n\nTwo shapes. They are not equivalent.\n\n```python\nfrom langgraph.types import Command\n\n# Shape A — resume only: human approved as-is\ngraph.invoke(Command(resume=\"approved\"), config)\n\n# Shape B — update + resume: human edited state mid-graph\ngraph.invoke(\n    Command(update={\"recipient\": \"new@example.com\"}, resume=\"approved\"),\n    config,\n)\n```\n\n`resume=\"...\"` is the value returned from inline `interrupt()` inside the\nnode (if any). For `interrupt_before` \u002F `interrupt_after`, no node reads\n`resume`, but the checkpoint records it for audit.\n\n`update={...}` merges into state via the reducer declared in the `TypedDict`.\n**Without a reducer, `update` replaces the field** (P18). Always annotate\nlist and dict state:\n\n```python\nfrom typing import Annotated, TypedDict\nfrom langchain_core.messages import AnyMessage\nfrom langgraph.graph.message import add_messages\n\nclass AgentState(TypedDict):\n    messages: Annotated[list[AnyMessage], add_messages]      # append, not replace\n    approvals: Annotated[list[dict], lambda l, r: l + r]     # custom append reducer\n    draft: Annotated[dict, lambda l, r: {**l, **r}]          # dict merge reducer\n    last_decision: str                                        # scalar: replace is fine\n```\n\nSee [Resume Patterns](references\u002Fresume-patterns.md) for the five canonical\nresume shapes (plain approve, approve with edits, reject to `END`, partial\napproval, inline-interrupt structured return), the reducer cookbook, and the\naudit-log write order.\n\n### Step 4 — Wire the approval UI\n\nTwo HTTP endpoints. Keep them boring.\n\n**GET `\u002Fapprovals\u002Fpending`** lists paused threads:\n\n```json\n[\n  {\n    \"thread_id\": \"conv-abc123\",\n    \"checkpoint_id\": \"01JABC...\",\n    \"interrupted_at\": \"2026-04-21T15:32:11Z\",\n    \"node\": \"send_email\",\n    \"state_diff\": {\"draft\": {\"to\": \"user@example.com\", \"subject\": \"Welcome\"}}\n  }\n]\n```\n\n**POST `\u002Fapprovals\u002F\u003Cthread-id>\u002Fdecision`** applies the decision:\n\n```json\n{\n  \"decision\": \"approve\" | \"reject\" | \"edit\",\n  \"edits\": {\"recipient\": \"corrected@example.com\"},\n  \"approver\": \"jeremy@intentsolutions.io\",\n  \"reason\": \"Verified against ticket INT-4821\",\n  \"expected_checkpoint_id\": \"01JABC...\",\n  \"idempotency_key\": \"c2f5e8a0-...\"\n}\n```\n\nOptimistic concurrency (the `expected_checkpoint_id` check) matters the\nmoment two approvers open the same thread in two browser tabs. Without it,\nthe second click silently overwrites the first. Return `409 Conflict` on\nmismatch; UI refreshes.\n\nServer-side flow: authz → idempotency dedupe → checkpoint check → audit-log\nwrite (BEFORE mutation) → build `Command` → `graph.ainvoke(cmd, config)` →\naudit-log finalize.\n\nSee [Approval UI Wiring](references\u002Fapproval-ui-wiring.md) for the full\nHTTP contract with status codes, FastAPI implementation, Slack Block Kit\nmapping, state-diff redaction, and an audit-log schema compatible with SOC2\nevidence requirements.\n\n### Step 5 — Safe cancellation: route to `END` on reject\n\nWhen the human rejects, the gated node must NOT execute. Two clean patterns:\n\n**Pattern A — conditional edge after the interrupted node (preferred):**\n\n```python\nfrom langgraph.graph import END\n\ndef route_after_approval(state: AgentState) -> str:\n    if state.get(\"last_decision\") == \"rejected\":\n        return END\n    return \"send_email\"\n\nbuilder.add_conditional_edges(\"await_approval\", route_after_approval, {\n    \"send_email\": \"send_email\",\n    END: END,\n})\n```\n\n**Pattern B — `Command(goto=END)` at resume:**\n\n```python\ngraph.invoke(Command(resume=\"rejected\", goto=END), config)\n```\n\nPrefer Pattern A in production: graph topology stays the source of truth,\naudit replays work without the UI. Always log the rejection to the checkpoint\nvia `Command(update={\"last_decision\": \"rejected\", \"reject_reason\": ...})`\nBEFORE routing to END — otherwise the audit trail lives only in the UI DB.\n\n### Step 6 — Native interrupts vs a separate approval service\n\n| Dimension | LangGraph interrupts | Separate approval service |\n|-----------|---------------------|---------------------------|\n| **Latency** | 50-300 ms pause + human time | Human time + queue latency |\n| **State coherence** | Single source of truth (checkpoint) | Two systems to reconcile |\n| **Concurrency** | Checkpoint-based optimistic locking | Whatever the queue provides |\n| **Multi-graph** | Per-graph, per-thread | Centralized policy engine |\n| **Observability** | `get_state()` + checkpoint history | Separate audit system |\n| **Failure mode** | JSON-serialization at interrupt (P17) | Network partition between services |\n| **Best for** | Single LangGraph app, 1-10 approval types, \u003C1k\u002Fday | Multi-app enterprise, complex RBAC, 10k+\u002Fday |\n\nSingle LangGraph app with fewer than a dozen approval types: native\ninterrupts are simpler and more reliable. Cross-app approval platform with\nescalations, delegations, and SLAs: run a dedicated service and call it from\na tool, not from an interrupt.\n\n## Output\n\n- Graph compiled with explicit `interrupt_before` \u002F `interrupt_after` lists, or inline `interrupt()` calls where payload structure matters\n- JSON-only state: `datetime` → ISO strings, `bytes` → base64, Pydantic → `.model_dump(mode=\"json\")`, custom classes → dicts\n- `TypedDict` state with explicit reducers on every list and dict field\n- Pre-interrupt state scanner attached as middleware or called at node exits; raises `NonSerializableStateError` with a key path\n- Approval HTTP endpoints: GET pending with state diffs, POST decision with `expected_checkpoint_id` optimistic-concurrency check and `idempotency_key` dedupe\n- Rejection routes to `END` via conditional edge (Pattern A) with `last_decision` recorded in state for audit\n- Audit log written BEFORE state mutation with `approver`, `reason`, `thread_id`, `checkpoint_id_before`, `checkpoint_id_after`\n\n## Error Handling\n\n| Error | Cause | Fix |\n|-------|-------|-----|\n| `TypeError: Object of type datetime is not JSON serializable` at interrupt | Non-JSON value in state (P17) | Convert at node boundary; add pre-interrupt scanner in CI |\n| Resume with `Command(update={\"messages\": [new]})` loses history | `messages` field missing reducer (P18) | Annotate as `Annotated[list[AnyMessage], add_messages]` |\n| `ValueError: Thread ... has no interrupted nodes` on resume | Graph already ran to completion, or `thread_id` mismatch | Call `graph.get_state(config)` first; assert `snapshot.next` is non-empty |\n| Human clicks approve, nothing happens | Missing checkpointer on `compile()` — interrupts require persistence | `graph.compile(checkpointer=MemorySaver() or PostgresSaver(...))` |\n| Two approvers both click approve, second one's edits win silently | No optimistic concurrency | Include `expected_checkpoint_id` in POST body; return 409 on mismatch |\n| `KeyError: 'configurable'` at resume | `config` dict missing `thread_id` | `config = {\"configurable\": {\"thread_id\": tid}}` — required by every checkpointer |\n| Approval UI shows stale state after another approver acted | Cached GET \u002Fpending response | `Cache-Control: no-store` on the pending endpoint |\n| Graph halts silently after reject | Conditional edge router returned value not in `path_map` | Include `END` in `path_map`; assert router output in keyset |\n\n## Examples\n\n### Approval gate before an expensive tool\n\nEmail-sending agent that must not send without approval. State carries\n`draft: {to, subject, body}`, graph compiles with\n`interrupt_before=[\"send_email\"]`, resume either invokes the send tool or\nroutes to `END` on reject. See\n[Resume Patterns](references\u002Fresume-patterns.md) for the full worked example\nincluding audit-log write order.\n\n### Partial approval — approve one argument, edit another\n\nHuman accepts the recipient but rewrites the subject. Resume is\n`Command(update={\"draft\": {**state[\"draft\"], \"subject\": new_subject}}, resume=\"approved\")`.\nNote the spread — without it the draft is replaced. Scalar dicts replace by\ndefault; declare a dict reducer to merge partials cleanly. See\n[Resume Patterns](references\u002Fresume-patterns.md).\n\n### Inline `interrupt()` with a custom payload\n\nInside a `validate_purchase` node, the model has decided to buy three items\nat USD 450 total. The node calls\n`decision = interrupt({\"kind\": \"confirm_purchase\", \"items\": items, \"total\": 450})`\nand the UI reads the payload to render a rich confirmation dialog. On resume,\n`decision` is whatever the UI sent via\n`Command(resume={\"approved\": True, \"notes\": \"...\"})`. See\n[Interrupt Decision Tree](references\u002Finterrupt-decision-tree.md).\n\n### Slack-driven approval\n\nGET \u002Fpending feeds a cron that posts Block Kit messages with approve\u002Freject\nbuttons. Button callback POSTs to \u002Fdecision. Slack's interaction payload\ncarries `user.id`, which becomes `approver` in the audit log. See\n[Approval UI Wiring](references\u002Fapproval-ui-wiring.md) for the Block Kit\ntemplate and signing-secret validation.\n\n## Resources\n\n- [LangGraph: Human-in-the-loop (concepts)](https:\u002F\u002Flangchain-ai.github.io\u002Flanggraph\u002Fconcepts\u002Fhuman_in_the_loop\u002F)\n- [LangGraph: How to add human-in-the-loop](https:\u002F\u002Flangchain-ai.github.io\u002Flanggraph\u002Fhow-tos\u002Fhuman_in_the_loop\u002F)\n- [LangGraph: `Command` type reference](https:\u002F\u002Flangchain-ai.github.io\u002Flanggraph\u002Freference\u002Ftypes\u002F#langgraph.types.Command)\n- [LangGraph: `interrupt` function reference](https:\u002F\u002Flangchain-ai.github.io\u002Flanggraph\u002Freference\u002Ftypes\u002F#langgraph.types.interrupt)\n- [LangGraph: Persistence and checkpointers](https:\u002F\u002Flangchain-ai.github.io\u002Flanggraph\u002Fconcepts\u002Fpersistence\u002F)\n- [LangGraph 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)\n- Related skills: `langchain-langgraph-basics`, `langchain-langgraph-checkpointing`, `langchain-middleware-patterns`\n","# LangChain LangGraph Human-in-the-Loop (Python)\n\n## Overview\n\nA team adds `interrupt_before=[\"send_email\"]` to require a human approval\nbefore the email goes out. First integration test crashes at the interrupt\nboundary with:\n\n```\nTypeError: Object of type datetime is not JSON serializable\n```\n\nThe culprit is two nodes upstream: a `classify` node stashed\n`\"received_at\": datetime.utcnow()` into state. Every node-level unit test\npassed because node completion does not serialize state — only the\ncheckpointer does, and only at supersteps that include an interrupt. The\nfailure is invisible until interrupt time (P17).\n\nA week later the resume path ships. The human reviews the draft, clicks\n\"approve with edits,\" and the backend runs:\n\n```python\ngraph.invoke(Command(update={\"messages\": [corrected_msg]}, resume=\"approved\"), config)\n```\n\nThe prior 47 messages vanish. `messages` was typed as plain\n`list[AnyMessage]` with no reducer, so `update` replaces the field instead of\nappending (P18).\n\nThis skill covers: three interrupt styles (`interrupt_before`,\n`interrupt_after`, inline `interrupt()`), the JSON-only state invariant with\na pre-interrupt scanner, the `Command(resume=...)` \u002F\n`Command(update=..., resume=...)` contract, an approval UI wire format\n(GET pending \u002F POST decision with optimistic concurrency), safe-cancellation\nrouting to `END`, and the tradeoff between native interrupts and a separate\napproval service. Pin: `langgraph 1.0.x`, `langgraph-checkpoint 2.0.x`.\nPain-catalog anchors: **P17**, **P18** (adjacent: P16, P20).\n\n## Prerequisites\n\n- Python 3.10+\n- `langgraph >= 1.0, \u003C 2.0`\n- A checkpointer: `MemorySaver` (dev), `PostgresSaver` (prod), or `SqliteSaver` (single-box)\n- A `thread_id` contract at the app boundary (see `langchain-langgraph-checkpointing`)\n- Familiarity with `langchain-langgraph-basics` — nodes, edges, `TypedDict` state with reducers\n\n## Instructions\n\n### Step 1 — Choose the interrupt style\n\nLangGraph 1.0 exposes three interrupt mechanisms. They are not interchangeable.\n\n| Style | Syntax | Use when |\n|-------|--------|----------|\n| `interrupt_before=[node]` | `compile(interrupt_before=[\"send_email\"])` | Review inputs before an irreversible tool. Graph pauses *before* node runs. State shown is the input. |\n| `interrupt_after=[node]` | `compile(interrupt_after=[\"draft_email\"])` | Review output of a node (e.g., an LLM draft). Graph pauses *after* node completes. |\n| Inline `interrupt()` | Inside a node: `decision = interrupt({\"kind\": \"...\"})` | Structured prompt mid-node with custom payload. Most flexible; lives in node code. |\n\nRule of thumb: prefer `interrupt_before` for hard gates (tool must not run\nwithout approval). Use `interrupt_after` for review loops (draft → approve →\nsend). Use inline `interrupt()` when the prompt varies on intermediate\ncomputation.\n\nTypical interrupt round-trip latency in production is **50-300 ms** from\npause to checkpoint write (local Postgres) plus UI time; budget **1-5 s**\ntotal for a Slack-based approval. Checkpoint row sizes average **2-20 KB** on\nsmall graphs and cap at **~1 MB** on `PostgresSaver` before historical\ncheckpoints need pruning.\n\nSee [Interrupt Decision Tree](references\u002Finterrupt-decision-tree.md) for full\ncriteria, multiple-interrupt-per-graph patterns, and the interrupt-vs-tool\ncomparison.\n\n### Step 2 — Enforce the JSON-serializable state invariant (P17)\n\nCheckpointers serialize state to JSON on every superstep. Any non-JSON type\nraises `TypeError` at the interrupt boundary — not at the offending node.\nCanonical offenders:\n\n| Type | Fix |\n|------|-----|\n| `datetime` \u002F `date` | `dt.isoformat()` — ISO 8601 string |\n| `bytes` | `base64.b64encode(b).decode()` |\n| `set` | `sorted(s)` |\n| Pydantic `BaseModel` with non-primitive fields | `.model_dump(mode=\"json\")` |\n| Custom classes | `dataclasses.asdict(obj)` or `vars(obj)` |\n| `numpy.ndarray` | `.tolist()` |\n| `decimal.Decimal` | `str(d)` or `float(d)` (lossy) |\n| `float(\"nan\")` \u002F `float(\"inf\")` | `None` (JSON forbids them; some savers crash on `allow_nan=False`) |\n\nShip a pre-interrupt scanner in dev and CI:\n\n```python\nimport json\nfrom typing import Any\n\nclass NonSerializableStateError(TypeError):\n    \"\"\"Raised when state contains values the checkpointer cannot serialize.\"\"\"\n\ndef assert_state_is_json_serializable(state: dict[str, Any], *, path: str = \"state\") -> None:\n    \"\"\"Walk state depth-first and raise a typed error naming the offending key path.\"\"\"\n    _walk(state, path)\n\ndef _walk(v: Any, path: str) -> None:\n    if v is None or isinstance(v, (bool, int, float, str)):\n        return\n    if isinstance(v, list):\n        for i, item in enumerate(v):\n            _walk(item, f\"{path}[{i}]\")\n        return\n    if isinstance(v, dict):\n        for k, val in v.items():\n            _walk(val, f\"{path}.{k}\")\n        return\n    raise NonSerializableStateError(\n        f\"{path} is {type(v).__name__}, not JSON-serializable. \"\n        f\"Convert at node boundary.\"\n    )\n```\n\nCall `assert_state_is_json_serializable(state)` at the end of every node\npreceding an interrupt-flagged node, or attach as LangGraph middleware. In\nCI, run the full graph to interrupt against a fixture that exercises every\nbranch — the only way to catch P17 before prod.\n\nSee [State Serialization for Interrupts](references\u002Fstate-serialization-for-interrupts.md)\nfor the full forbidden-types list, the Pydantic-in-state pattern, and the\nintegration-test harness.\n\n### Step 3 — The resume contract\n\nTwo shapes. They are not equivalent.\n\n```python\nfrom langgraph.types import Command\n\n# Shape A — resume only: human approved as-is\ngraph.invoke(Command(resume=\"approved\"), config)\n\n# Shape B — update + resume: human edited state mid-graph\ngraph.invoke(\n    Command(update={\"recipient\": \"new@example.com\"}, resume=\"approved\"),\n    config,\n)\n```\n\n`resume=\"...\"` is the value returned from inline `interrupt()` inside the\nnode (if any). For `interrupt_before` \u002F `interrupt_after`, no node reads\n`resume`, but the checkpoint records it for audit.\n\n`update={...}` merges into state via the reducer declared in the `TypedDict`.\n**Without a reducer, `update` replaces the field** (P18). Always annotate\nlist and dict state:\n\n```python\nfrom typing import Annotated, TypedDict\nfrom langchain_core.messages import AnyMessage\nfrom langgraph.graph.message import add_messages\n\nclass AgentState(TypedDict):\n    messages: Annotated[list[AnyMessage], add_messages]      # append, not replace\n    approvals: Annotated[list[dict], lambda l, r: l + r]     # custom append reducer\n    draft: Annotated[dict, lambda l, r: {**l, **r}]          # dict merge reducer\n    last_decision: str                                        # scalar: replace is fine\n```\n\nSee [Resume Patterns](references\u002Fresume-patterns.md) for the five canonical\nresume shapes (plain approve, approve with edits, reject to `END`, partial\napproval, inline-interrupt structured return), the reducer cookbook, and the\naudit-log write order.\n\n### Step 4 — Wire the approval UI\n\nTwo HTTP endpoints. Keep them boring.\n\n**GET `\u002Fapprovals\u002Fpending`** lists paused threads:\n\n```json\n[\n  {\n    \"thread_id\": \"conv-abc123\",\n    \"checkpoint_id\": \"01JABC...\",\n    \"interrupted_at\": \"2026-04-21T15:32:11Z\",\n    \"node\": \"send_email\",\n    \"state_diff\": {\"draft\": {\"to\": \"user@example.com\", \"subject\": \"Welcome\"}}\n  }\n]\n```\n\n**POST `\u002Fapprovals\u002F\u003Cthread-id>\u002Fdecision`** applies the decision:\n\n```json\n{\n  \"decision\": \"approve\" | \"reject\" | \"edit\",\n  \"edits\": {\"recipient\": \"corrected@example.com\"},\n  \"approver\": \"jeremy@intentsolutions.io\",\n  \"reason\": \"Verified against ticket INT-4821\",\n  \"expected_checkpoint_id\": \"01JABC...\",\n  \"idempotency_key\": \"c2f5e8a0-...\"\n}\n```\n\nOptimistic concurrency (the `expected_checkpoint_id` check) matters the\nmoment two approvers open the same thread in two browser tabs. Without it,\nthe second click silently overwrites the first. Return `409 Conflict` on\nmismatch; UI refreshes.\n\nServer-side flow: authz → idempotency dedupe → checkpoint check → audit-log\nwrite (BEFORE mutation) → build `Command` → `graph.ainvoke(cmd, config)` →\naudit-log finalize.\n\nSee [Approval UI Wiring](references\u002Fapproval-ui-wiring.md) for the full\nHTTP contract with status codes, FastAPI implementation, Slack Block Kit\nmapping, state-diff redaction, and an audit-log schema compatible with SOC2\nevidence requirements.\n\n### Step 5 — Safe cancellation: route to `END` on reject\n\nWhen the human rejects, the gated node must NOT execute. Two clean patterns:\n\n**Pattern A — conditional edge after the interrupted node (preferred):**\n\n```python\nfrom langgraph.graph import END\n\ndef route_after_approval(state: AgentState) -> str:\n    if state.get(\"last_decision\") == \"rejected\":\n        return END\n    return \"send_email\"\n\nbuilder.add_conditional_edges(\"await_approval\", route_after_approval, {\n    \"send_email\": \"send_email\",\n    END: END,\n})\n```\n\n**Pattern B — `Command(goto=END)` at resume:**\n\n```python\ngraph.invoke(Command(resume=\"rejected\", goto=END), config)\n```\n\nPrefer Pattern A in production: graph topology stays the source of truth,\naudit replays work without the UI. Always log the rejection to the checkpoint\nvia `Command(update={\"last_decision\": \"rejected\", \"reject_reason\": ...})`\nBEFORE routing to END — otherwise the audit trail lives only in the UI DB.\n\n### Step 6 — Native interrupts vs a separate approval service\n\n| Dimension | LangGraph interrupts | Separate approval service |\n|-----------|---------------------|---------------------------|\n| **Latency** | 50-300 ms pause + human time | Human time + queue latency |\n| **State coherence** | Single source of truth (checkpoint) | Two systems to reconcile |\n| **Concurrency** | Checkpoint-based optimistic locking | Whatever the queue provides |\n| **Multi-graph** | Per-graph, per-thread | Centralized policy engine |\n| **Observability** | `get_state()` + checkpoint history | Separate audit system |\n| **Failure mode** | JSON-serialization at interrupt (P17) | Network partition between services |\n| **Best for** | Single LangGraph app, 1-10 approval types, \u003C1k\u002Fday | Multi-app enterprise, complex RBAC, 10k+\u002Fday |\n\nSingle LangGraph app with fewer than a dozen approval types: native\ninterrupts are simpler and more reliable. Cross-app approval platform with\nescalations, delegations, and SLAs: run a dedicated service and call it from\na tool, not from an interrupt.\n\n## Output\n\n- Graph compiled with explicit `interrupt_before` \u002F `interrupt_after` lists, or inline `interrupt()` calls where payload structure matters\n- JSON-only state: `datetime` → ISO strings, `bytes` → base64, Pydantic → `.model_dump(mode=\"json\")`, custom classes → dicts\n- `TypedDict` state with explicit reducers on every list and dict field\n- Pre-interrupt state scanner attached as middleware or called at node exits; raises `NonSerializableStateError` with a key path\n- Approval HTTP endpoints: GET pending with state diffs, POST decision with `expected_checkpoint_id` optimistic-concurrency check and `idempotency_key` dedupe\n- Rejection routes to `END` via conditional edge (Pattern A) with `last_decision` recorded in state for audit\n- Audit log written BEFORE state mutation with `approver`, `reason`, `thread_id`, `checkpoint_id_before`, `checkpoint_id_after`\n\n## Error Handling\n\n| Error | Cause | Fix |\n|-------|-------|-----|\n| `TypeError: Object of type datetime is not JSON serializable` at interrupt | Non-JSON value in state (P17) | Convert at node boundary; add pre-interrupt scanner in CI |\n| Resume with `Command(update={\"messages\": [new]})` loses history | `messages` field missing reducer (P18) | Annotate as `Annotated[list[AnyMessage], add_messages]` |\n| `ValueError: Thread ... has no interrupted nodes` on resume | Graph already ran to completion, or `thread_id` mismatch | Call `graph.get_state(config)` first; assert `snapshot.next` is non-empty |\n| Human clicks approve, nothing happens | Missing checkpointer on `compile()` — interrupts require persistence | `graph.compile(checkpointer=MemorySaver() or PostgresSaver(...))` |\n| Two approvers both click approve, second one's edits win silently | No optimistic concurrency | Include `expected_checkpoint_id` in POST body; return 409 on mismatch |\n| `KeyError: 'configurable'` at resume | `config` dict missing `thread_id` | `config = {\"configurable\": {\"thread_id\": tid}}` — required by every checkpointer |\n| Approval UI shows stale state after another approver acted | Cached GET \u002Fpending response | `Cache-Control: no-store` on the pending endpoint |\n| Graph halts silently after reject | Conditional edge router returned value not in `path_map` | Include `END` in `path_map`; assert router output in keyset |\n\n## Examples\n\n### Approval gate before an expensive tool\n\nEmail-sending agent that must not send without approval. State carries\n`draft: {to, subject, body}`, graph compiles with\n`interrupt_before=[\"send_email\"]`, resume either invokes the send tool or\nroutes to `END` on reject. See\n[Resume Patterns](references\u002Fresume-patterns.md) for the full worked example\nincluding audit-log write order.\n\n### Partial approval — approve one argument, edit another\n\nHuman accepts the recipient but rewrites the subject. Resume is\n`Command(update={\"draft\": {**state[\"draft\"], \"subject\": new_subject}}, resume=\"approved\")`.\nNote the spread — without it the draft is replaced. Scalar dicts replace by\ndefault; declare a dict reducer to merge partials cleanly. See\n[Resume Patterns](references\u002Fresume-patterns.md).\n\n### Inline `interrupt()` with a custom payload\n\nInside a `validate_purchase` node, the model has decided to buy three items\nat USD 450 total. The node calls\n`decision = interrupt({\"kind\": \"confirm_purchase\", \"items\": items, \"total\": 450})`\nand the UI reads the payload to render a rich confirmation dialog. On resume,\n`decision` is whatever the UI sent via\n`Command(resume={\"approved\": True, \"notes\": \"...\"})`. See\n[Interrupt Decision Tree](references\u002Finterrupt-decision-tree.md).\n\n### Slack-driven approval\n\nGET \u002Fpending feeds a cron that posts Block Kit messages with approve\u002Freject\nbuttons. Button callback POSTs to \u002Fdecision. Slack's interaction payload\ncarries `user.id`, which becomes `approver` in the audit log. See\n[Approval UI Wiring](references\u002Fapproval-ui-wiring.md) for the Block Kit\ntemplate and signing-secret validation.\n\n## Resources\n\n- [LangGraph: Human-in-the-loop (concepts)](https:\u002F\u002Flangchain-ai.github.io\u002Flanggraph\u002Fconcepts\u002Fhuman_in_the_loop\u002F)\n- [LangGraph: How to add human-in-the-loop](https:\u002F\u002Flangchain-ai.github.io\u002Flanggraph\u002Fhow-tos\u002Fhuman_in_the_loop\u002F)\n- [LangGraph: `Command` type reference](https:\u002F\u002Flangchain-ai.github.io\u002Flanggraph\u002Freference\u002Ftypes\u002F#langgraph.types.Command)\n- [LangGraph: `interrupt` function reference](https:\u002F\u002Flangchain-ai.github.io\u002Flanggraph\u002Freference\u002Ftypes\u002F#langgraph.types.interrupt)\n- [LangGraph: Persistence and checkpointers](https:\u002F\u002Flangchain-ai.github.io\u002Flanggraph\u002Fconcepts\u002Fpersistence\u002F)\n- [LangGraph 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)\n- Related skills: `langchain-langgraph-basics`, `langchain-langgraph-checkpointing`, `langchain-middleware-patterns`\n",{"name":5,"tags":24,"author":33,"license":15,"version":34,"description":35,"allowed-tools":36,"compatible-with":37},[25,26,27,28,29,30,31,32],"saas","langchain","langgraph","python","langchain-1.0","human-in-loop","approval","interrupts","Jeremy Longshore \u003Cjeremy@intentsolutions.io>","2.0.0","Build LangGraph 1.0 human-in-the-loop approval flows with `interrupt_before` \u002F\n`interrupt_after` and `Command(resume=...)` — JSON-serializable state, clean\nresume semantics, and UI wiring for approval decisions. Use when adding an\napproval gate before an expensive tool call, wiring a Slack\u002Fweb UI for agent\napprovals, or debugging a graph that crashes on interrupt.\nTrigger with \"langgraph human in loop\", \"langgraph interrupt_before\",\n\"langgraph approval flow\", \"Command resume\", \"langgraph HITL\".\n","Read, Write, Edit, Bash(python:*)","claude-code, codex","main","99825ad3f3bcc6597ddcc7294a14e6e922f2b67b","skills\u002Fsaas-packs--langchain-py-pack--langchain-langgraph-human-in-loop",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":48,"prompt":58,"zipAvailable":59},[49,52,55],{"tool":50,"command":51},"npx","npx skills add jukeyman\u002Fjukeyman-skills --skill langchain-langgraph-human-in-loop",{"tool":53,"command":54},"bunx","bunx skills add jukeyman\u002Fjukeyman-skills --skill langchain-langgraph-human-in-loop",{"tool":56,"command":57},"pnpm","pnpm dlx skills add jukeyman\u002Fjukeyman-skills --skill langchain-langgraph-human-in-loop","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fsaas-packs--langchain-py-pack--langchain-langgraph-human-in-loop\u002FSKILL.md",true,[],[62,69,76,83,90,98],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"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":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"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":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"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":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"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":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":94,"sourceHtmlUrl":95,"categories":96,"keywords":97,"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":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"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",[],[]]