跳至内容

错误

GraphRecursionError

基类: RecursionError

当图耗尽最大步数时引发。

这可以防止无限循环。要增加最大步数,请使用指定更高 recursion_limit 的配置运行您的图。

示例

graph = builder.compile()
graph.invoke(
    {"messages": [("user", "Hello, world!")]},
    # The config is the second positional argument
    {"recursion_limit": 1000},
)
源代码在 libs/langgraph/langgraph/errors.py
class GraphRecursionError(RecursionError):
    """Raised when the graph has exhausted the maximum number of steps.

    This prevents infinite loops. To increase the maximum number of steps,
    run your graph with a config specifying a higher `recursion_limit`.

    Examples:

        graph = builder.compile()
        graph.invoke(
            {"messages": [("user", "Hello, world!")]},
            # The config is the second positional argument
            {"recursion_limit": 1000},
        )
    """

    pass

InvalidUpdateError

基类: Exception

当尝试使用一组无效的更新来更新通道时引发。

源代码在 libs/langgraph/langgraph/errors.py
class InvalidUpdateError(Exception):
    """Raised when attempting to update a channel with an invalid set of updates."""

    pass

GraphInterrupt

基类: Exception

当子图被中断时引发,被根图抑制。从不直接引发或向用户展示。

源代码在 libs/langgraph/langgraph/errors.py
class GraphInterrupt(Exception):
    """Raised when a subgraph is interrupted, suppressed by the root graph.
    Never raised directly, or surfaced to the user."""

    def __init__(self, interrupts: Sequence[Interrupt] = ()) -> None:
        super().__init__(interrupts)

NodeInterrupt

基类: GraphInterrupt

由节点引发以中断执行。

源代码在 libs/langgraph/langgraph/errors.py
class NodeInterrupt(GraphInterrupt):
    """Raised by a node to interrupt execution."""

    def __init__(self, value: Any) -> None:
        super().__init__([Interrupt(value)])

GraphDelegate

基类: Exception

当图被委托(用于分布式模式)时引发。

源代码在 libs/langgraph/langgraph/errors.py
class GraphDelegate(Exception):
    """Raised when a graph is delegated (for distributed mode)."""

    def __init__(self, *args: dict[str, Any]) -> None:
        super().__init__(*args)

EmptyInputError

基类: Exception

当图接收空输入时引发。

源代码在 libs/langgraph/langgraph/errors.py
class EmptyInputError(Exception):
    """Raised when graph receives an empty input."""

    pass

TaskNotFound

基类: Exception

当执行器无法找到任务(用于分布式模式)时引发。

源代码在 libs/langgraph/langgraph/errors.py
class TaskNotFound(Exception):
    """Raised when the executor is unable to find a task (for distributed mode)."""

    pass

CheckpointNotLatest

基类: Exception

当检查点不是最新版本(用于分布式模式)时引发。

源代码在 libs/langgraph/langgraph/errors.py
class CheckpointNotLatest(Exception):
    """Raised when the checkpoint is not the latest version (for distributed mode)."""

    pass

MultipleSubgraphsError

基类: Exception

当在同一个节点内调用多个子图时引发。

源代码在 libs/langgraph/langgraph/errors.py
class MultipleSubgraphsError(Exception):
    """Raised when multiple subgraphs are called inside the same node."""

    pass

评论