666ghj/MiroFish · error · ValueError
启用图谱记忆更新时必须提供 graph_id
Error message
启用图谱记忆更新时必须提供 graph_id
What it means
Raised in SimulationRunner's start path: when enable_graph_memory_update is true, graph_id must be supplied; otherwise ValueError('启用图谱记忆更新时必须提供 graph_id'). The graph memory updater writes agent activity back to a specific Zep graph, and without a target graph id there is nothing valid to write to — the code prefers failing over silently disabling the feature.
Source
Thrown at backend/app/services/simulation_runner.py:443
# STARTING state makes every concurrent start fail closed.
with cls._finalization_lock(simulation_id):
existing = cls.get_run_state(simulation_id)
active_statuses = {
RunnerStatus.STARTING,
RunnerStatus.RUNNING,
RunnerStatus.PAUSED,
RunnerStatus.STOPPING,
}
if (
existing and existing.runner_status in active_statuses
) or ZepGraphMemoryManager.get_updater(simulation_id) is not None:
raise ValueError(f"模拟已在运行或结束处理中: {simulation_id}")
cls._save_run_state(state)
# 如果启用图谱记忆更新,创建更新器
if enable_graph_memory_update:
if not graph_id:
raise ValueError("启用图谱记忆更新时必须提供 graph_id")
try:
ZepGraphMemoryManager.create_updater(simulation_id, graph_id)
cls._graph_memory_enabled[simulation_id] = True
logger.info(f"已启用图谱记忆更新: simulation_id={simulation_id}, graph_id={graph_id}")
except Exception as e:
logger.error(f"创建图谱记忆更新器失败: {e}")
cls._graph_memory_enabled[simulation_id] = False
state.runner_status = RunnerStatus.FAILED
state.error = f"Zep图谱更新器初始化失败: {e}"
with cls._finalization_lock(simulation_id):
cls._save_run_state(state)
cls._sync_simulation_status(
simulation_id,
RunnerStatus.FAILED,
state.error,
)
raise RuntimeError(state.error) from eView on GitHub (pinned to b5b53acc57)
Solutions
- Pass the project's Zep graph_id whenever enable_graph_memory_update is true.
- Or set enable_graph_memory_update=false if you don't need agent activity written back to the graph.
- Validate the pairing at the API boundary so the request fails with a 422 before reaching the runner.
- In the frontend, auto-fill graph_id from the project when the toggle is enabled and disable start until present.
Example fix
# before
runner.start_simulation(sim_id, enable_graph_memory_update=True) # graph_id omitted
# after
runner.start_simulation(
sim_id,
enable_graph_memory_update=True,
graph_id=project.graph_id, # from the project/graph that was built
) Defensive patterns
Strategy: validation
Validate before calling
if enable_graph_memory_update and not graph_id:
raise HTTPException(422, 'graph_id is required when enable_graph_memory_update is true') Prevention
- Validate the (enable_graph_memory_update, graph_id) pairing in the API schema (FastAPI dependency or pydantic model_validator).
- Auto-populate graph_id from the project in the frontend when the toggle is on.
- Reject empty-string graph_id the same as missing — both are falsy.
When it happens
Trigger: Calling start with enable_graph_memory_update=True but omitting graph_id (e.g. the route's optional graph_id field left null by the client); passing an empty string graph_id (falsy); frontend not propagating the project's graph_id when the toggle is enabled.
Common situations: New UI toggle for graph memory shipped without wiring the graph_id field; API clients copying an old request body that predates the feature; graph_id passed under a different JSON key than the route expects.
Related errors
- Zep图谱更新器初始化失败: {e}
- 模拟仍在停止中,图谱写入未在 {wait_timeout:.0f}s 内完成
- Zep图谱写入未完整完成: {error}
- graph_id is required
- At least one text chunk is required
AI-assisted analysis of 666ghj/MiroFish@b5b53acc57 (2026-08-14).
Data as JSON: /api/errors/258db727475c08c2.
Report an issue: GitHub.