666ghj/MiroFish · error · ValueError
模拟不存在: {simulation_id}
Error message
模拟不存在: {simulation_id} What it means
Raised in SimulationManager.prepare_simulation: it loads persisted simulation state via _load_simulation_state(simulation_id), and if no state file exists it raises ValueError('模拟不存在: ...'). This is a plain not-found guard — the simulation id was never created (or its state file was deleted) before prepare was called.
Source
Thrown at backend/app/services/simulation_manager.py:278
3. 使用LLM智能生成模拟配置参数(时间、活跃度、发言频率等)
4. 保存配置文件和Profile文件
5. 复制预设脚本到模拟目录
Args:
simulation_id: 模拟ID
simulation_requirement: 模拟需求描述(用于LLM生成配置)
document_text: 原始文档内容(用于LLM理解背景)
defined_entity_types: 预定义的实体类型(可选)
use_llm_for_profiles: 是否使用LLM生成详细人设
progress_callback: 进度回调函数 (stage, progress, message)
parallel_profile_count: 并行生成人设的数量,默认3
Returns:
SimulationState
"""
state = self._load_simulation_state(simulation_id)
if not state:
raise ValueError(f"模拟不存在: {simulation_id}")
try:
state.status = SimulationStatus.PREPARING
state.error = None
state.profiles_generated = False
state.config_generated = False
state.config_reasoning = ""
self._save_simulation_state(state)
sim_dir = self._get_simulation_dir(simulation_id)
# ========== 阶段1: 读取并过滤实体 ==========
if progress_callback:
progress_callback("reading", 0, t('progress.connectingZepGraph'))
reader = ZepEntityReader()
if progress_callback:View on GitHub (pinned to b5b53acc57)
Solutions
- Create the simulation first via the create endpoint, then call prepare with the returned id.
- Verify the state file exists on disk in the manager's simulation directory for that id (list simulations via the manager's list method).
- If state was lost due to container recreation, remount the persistent volume holding simulation state and retry.
- Check for id truncation/encoding issues in the client (whitespace, wrong copy).
Example fix
# before
manager.prepare_simulation('sim-123', ...)
# after
if not manager._load_simulation_state('sim-123'):
state = manager.create_simulation(project_id='p1', ...) # get real id
manager.prepare_simulation(state.simulation_id, ...) Defensive patterns
Strategy: validation
Validate before calling
if not manager._load_simulation_state(simulation_id):
raise HTTPException(404, f'simulation {simulation_id} not found') Try / catch
try:
manager.prepare_simulation(sim_id, ...)
except ValueError as e:
if '不存在' in str(e):
raise HTTPException(404, str(e)) from e
raise Prevention
- Mount simulation state on a persistent volume so restarts don't lose it.
- Return 404 from routes when the not-found ValueError fires, not 500.
- Have the frontend refresh its simulation list after environment resets.
When it happens
Trigger: Calling prepare with an id that was never registered through create_simulation; state files wiped (deleted data dir, fresh container without a volume); typo'd or truncated simulation_id from the client; calling prepare on a simulation from a different backend instance.
Common situations: Backend restarted against a new/empty persistence directory; Docker volume for simulation state not mounted; frontend holding a stale id after environment reset; manual cleanup of the simulations directory.
Related errors
- 不支持的平台: {platform}
- 模拟配置不存在,请先调用 /prepare 接口
- 启用图谱记忆更新时必须提供 graph_id
- Star count file is not a regular file
- t('step5.selectAgentFirst')
AI-assisted analysis of 666ghj/MiroFish@b5b53acc57 (2026-08-14).
Data as JSON: /api/errors/4ed3d0126e26720d.
Report an issue: GitHub.