You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

执行langgraph dev命令触发GraphLoadError:无法加载指定图的问题排查求助

执行langgraph dev命令触发GraphLoadError:无法加载指定图的问题排查求助

大家好,我最近在开发一个简单的LangGraph智能体Demo,卡在了部署环节,想请各位帮忙排查下问题:

问题场景

我已经成功跑完了核心代码测试(就是个简单的智能体Demo),也通过pip install -e .完成了本地开发环境的安装。但当我尝试把智能体部署成LangGraph Server,执行命令langgraph dev .时,直接抛出了加载错误:

langgraph_api.utils.errors.GraphLoadError: Failed to load graph 'Graph with Memory' from src/agent/graph.py: No module named 'agent'

我的项目关键配置与结构

  1. langgraph.json 完整配置
{
  "$schema": "https://langgra.ph/schema.json",
  "dependencies": ["."],
  "graphs": {
    "Graph with Memory": "src/agent/graph.py:graph"
  },
  "env": ".env",
  "image_distro": "wolfi",
  "store": {
    "index": {
      "embed": "src/agent/llm/models.py:get_embeddings",
      "dimensions": 1024,
      "fields": ["content.memory_fragments[*].content", "content.memory_fragments[*].scene"]
    }
  }
}
  1. graph.py 核心代码片段
# 前面的工作流定义代码省略
graph = workflow.compile(name="Graph with Memory", checkpointer=my_checkpointer, store=my_store)
  1. 项目目录结构(大致)
我的项目根目录/
├── src/
│   └── agent/
│       ├── __init__.py
│       ├── graph.py
│       └── llm/
│           ├── __init__.py
│           └── models.py
├── langgraph.json
├── .env
└── pyproject.toml(本地开发依赖配置文件)

我已经试过的排查操作

  • 确认pip install -e .执行无报错,本地Python环境里能正常import agent模块
  • 检查graph.py里的graph变量确实存在,且工作流编译逻辑没问题
  • 反复核对langgraph.json里的路径、文件名、变量名,没发现拼写错误

想请教的问题

为什么本地能正常运行的代码,用langgraph dev部署时就找不到agent模块?是不是有什么路径配置或者LangGraph Server的加载逻辑我没搞清楚?麻烦各位帮忙看看,谢谢!

火山引擎 最新活动