Token导航 LogoToken导航TokenDH.com
待分类执行命令github未标认证来源可访问许可证需确认审计提醒

langgraph-error-handling语言图错误处理

Agent Skill

langgraph-error-handling 用于记录任务执行中的错误、用户纠正、经验和能力缺口,适合在 Codex、Claude、Cursor、Gemini CLI 中希望让 Agent 持续沉淀问题、修正和最佳实践时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

564

周安装

24

GitHub Stars

94

下载量

198
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:langgraph-error-handling(语言图错误处理)
来源仓库:https://github.com/lubu-labs/langchain-agent-skills
仓库路径:skills/langgraph-error-handling
安装命令:
npx skills add https://github.com/lubu-labs/langchain-agent-skills --skill langgraph-error-handling
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/lubu-labs/langchain-agent-skills --skill langgraph-error-handling

简介

用于记录任务执行中的错误、纠正和经验缺口。

  • 适合让 Agent 持续沉淀问题、修正和最佳实践。
  • 可结合来源仓库和原始 README 核验具体用法。
  • 安装命令:npx skills add https://github.com/lubu-labs/langchain-agent-skills --skill langgraph-error-handling。
  • 安装前建议确认权限范围和维护状态,避免触发不必要操作。

SKILL.md

LangGraph Error Handling

Use This Skill For

  • Adding RetryPolicy to flaky nodes (API, DB, model/tool calls)
  • Designing LLM recovery loops (Command + error state + retry counters)
  • Adding human approval/escalation with interrupt() and resume
  • Handling prebuilt ToolNode failures
  • Debugging transactional failure behavior in parallel supersteps

Strategy Selection

Use this order:

  1. Transient/infrastructure issue (429, timeout, 5xx, temporary DB lock) -> RetryPolicy
  2. Recoverable by model/tool args correction -> store error in state and route back with Command
  3. Needs user approval or missing info -> interrupt() + resume
  4. Unknown/programming bug -> let it bubble up and debug
Error TypeOwnerPrimary Mechanism
TransientSystemRetryPolicy
LLM-recoverableLLMState update + Command(goto=...)
User-fixableHumaninterrupt() + Command(resume=...)
UnexpectedDeveloperRaise/log/debug

For full taxonomy, load references/error-types.md.

Minimal Patterns

1) Retry Transient Failures

from langgraph.types import RetryPolicy

builder.add_node(
    "call_api",
    call_api,
    retry_policy=RetryPolicy(max_attempts=3, initial_interval=1.0),
)
builder.addNode("callApi", callApi, {
  retryPolicy: { maxAttempts: 3, initialInterval: 1.0 },
});

Notes:

  • Python and JS default retry behavior differs by exception type.
  • Prefer targeted retry_on/retryOn for non-transient domains.

2) LLM Recovery Loop

Use MessagesState in Python for message state.

from typing import Literal
from typing_extensions import NotRequired
from langgraph.graph import MessagesState
from langgraph.types import Command

class State(MessagesState):
    error: NotRequired[str]
    retry_count: NotRequired[int]

def agent(state: State) -> Command[Literal["tool", "__end__"]]:
    if state.get("retry_count", 0) >= 3:
        return Command(goto="__end__")
    if state.get("error"):
        return Command(goto="tool")
    return Command(goto="tool")
import { StateGraph, Command, END } from "@langchain/langgraph";

// If a node returns Command in JS, add `ends` on addNode.
builder.addNode("agent", agentNode, { ends: ["tool", END] });

3) Human-In-The-Loop Escalation

from langgraph.types import interrupt, Command

def human_review(state):
    approved = interrupt({
        "question": "Proceed?",
        "payload": state["pending_action"],
    })
    return Command(goto="execute" if approved else "cancel")

# resume
graph.invoke(Command(resume=True), config={"configurable": {"thread_id": "t-1"}})
import { Command, interrupt } from "@langchain/langgraph";

const approved = interrupt({ question: "Proceed?" });
// later
await graph.invoke(new Command({ resume: true }), {
  configurable: { thread_id: "t-1" },
});

Requirements:

  • Compile with a checkpointer for interrupt flows.
  • Reuse the same thread_id on resume.

For deep HITL patterns, load references/human-escalation.md.

ToolNode Error Handling

from langgraph.prebuilt import ToolNode

tool_node = ToolNode(tools, handle_tool_errors=True)
tool_node = ToolNode(tools, handle_tool_errors="Please try again.")
tool_node = ToolNode(tools, handle_tool_errors=(ValueError, TypeError))

Use custom handlers when you need deterministic error shaping for model recovery. For broader tool-recovery design, load references/llm-recovery.md.

Critical Behavior (Do Not Skip)

  1. Supersteps are transactional: one failing parallel branch fails the whole superstep state update.
  2. RetryPolicy retries failing branches, not successful siblings.
  3. interrupt() re-runs the node on resume: side effects before interrupt must be idempotent, or moved after interrupt / separate node.
  4. JS Command routing requires ends metadata on addNode(...).
  5. Use explicit retry limits (max_attempts, plus state counters for recovery loops).

Local Assets In This Skill

Scripts

  • scripts/classify_error.py: classify exception category and recommended handling
  • scripts/wrap_with_retry.py: generate boilerplate node wrappers with retry/recovery/escalation options

Run from repo root:

uv run skills/langgraph-error-handling/scripts/classify_error.py TimeoutError --verbose
uv run skills/langgraph-error-handling/scripts/wrap_with_retry.py call_llm --with-llm-recovery

Examples

  • assets/examples/retry-example/: retry + recovery loop (Python and JS)
  • assets/examples/human-loop-example/: interrupt/resume approval flow (Python and JS)

Load References On Demand

  • references/error-types.md: error taxonomy and classification rules
  • references/retry-strategies.md: retry tuning, backoff, circuit-breaker-style patterns
  • references/llm-recovery.md: recovery-loop and ToolNode strategies
  • references/human-escalation.md: human approval, interrupts, and escalation patterns

Common Failure Modes

SymptomRoot CauseFix
interrupt() fails at runtimeno checkpointercompile with checkpointer
Resume starts new rundifferent thread_idreuse same thread_id
JS Command route not takenmissing endsadd ends to addNode
Infinite loopno termination counter/conditionadd retry counter + terminal branch
Retry never triggersexception excluded by retry filterset explicit retry_on/retryOn

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.84%
按下载量换算69

Claude

31.29%
按下载量换算62

Cursor

16.79%
按下载量换算33

Gemini CLI

9.76%
按下载量换算19

安全审计

Gen Agent Trust Hub

可疑

Socket

通过

Snyk

通过

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/lubu-labs/langchain-agent-skills --skill langgraph-error-handling 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills