Skip to content

LangGraph Studio 故障排除

Safari连接问题

Safari会阻止本地主机上的普通HTTP流量。当使用langgraph dev运行Studio时,可能会看到“Failed to load assistants”错误。

解决方案1:使用Cloudflare Tunnel

pip install -U langgraph-cli>=0.2.6
langgraph dev --tunnel
# 需要 @langchain/langgraph-cli>=0.0.26
npx @langchain/langgraph-cli dev

该命令输出格式如下URL:

https://smith.langchain.com/studio/?baseUrl=https://hamilton-praise-heart-costumes.trycloudflare.com

在Safari中使用此URL加载Studio。此处的baseUrl参数指定您的代理服务器端点。

解决方案2:使用Chromium浏览器

Chrome及其他基于Chromium的浏览器允许在本地主机上使用HTTP。使用langgraph dev无需额外配置。

Brave 连接问题

当启用 Brave Shields 时,Brave 会阻止本地主机上的普通 HTTP 流量。在使用 langgraph dev 运行 Studio 时,你可能会看到“Failed to load assistants”(无法加载助手)的错误。

解决方案 1:禁用 Brave Shields

通过 URL 栏中的 Brave 图标,为 LangSmith 禁用 Brave Shields。

Brave Shields

解决方案 2:使用 Cloudflare Tunnel

pip install -U langgraph-cli>=0.2.6
langgraph dev --tunnel
# 需要 @langchain/langgraph-cli>=0.0.26
npx @langchain/langgraph-cli dev

该命令将输出如下格式的 URL:

https://smith.langchain.com/studio/?baseUrl=https://hamilton-praise-heart-costumes.trycloudflare.com

在 Brave 中使用此 URL 加载 Studio。此处,baseUrl 参数指定了你的代理服务器端点。

图形边问题

未定义的条件边可能会在你的图中显示意外的连接。这是因为没有正确定义时,LangGraph Studio 会假设条件边可以访问所有其他节点。为了解决这个问题,请使用以下方法之一显式定义路由路径:

解决方案 1:路径映射

定义路由器输出与目标节点之间的映射:

graph.add_conditional_edges("node_a", routing_function, {True: "node_b", False: "node_c"})
graph.addConditionalEdges("node_a", routingFunction, { true: "node_b", false: "node_c" });

解决方案 2:路由器类型定义(Python)

使用 Python 的 Literal 类型指定可能的路由目的地:

def routing_function(state: GraphState) -> Literal["node_b","node_c"]:
    if state['some_condition'] == True:
        return "node_b"
    else:
        return "node_c"