666ghj/MiroFish · error · ValueError
模拟环境未运行或已关闭,无法执行Interview
Error message
模拟环境未运行或已关闭,无法执行Interview: {simulation_id} What it means
After confirming the run directory exists, interview_agent builds a SimulationIPCClient over the run's IPC channel and calls check_env_alive(); if the OASIS environment process inside the simulation is not alive (not started, exited, or IPC socket dead), it refuses to send the Interview command with this ValueError.
Solutions
- Retry with backoff for the first ~30-60s after start until check_env_alive() passes (env boot takes time).
- Check the simulation's runner_status and env logs — if the env process exited, restart the simulation before interviewing.
- If a stale IPC socket is suspected (crashed prior run), clean the run directory / restart the simulation.
Example fix
// before
resp = SimulationRunner.interview_agent(sim_id, agent_id, prompt);
// after
from app.services.simulation_ipc import SimulationIPCClient
client = SimulationIPCClient(sim_dir)
for _ in range(12): # up to ~60s for env boot
if client.check_env_alive():
break
time.sleep(5)
else:
raise ServiceUnavailable(f"env for {sim_id} not alive")
resp = SimulationRunner.interview_agent(sim_id, agent_id, prompt); Defensive patterns
Strategy: retry
Validate before calling
from app.services.simulation_ipc import SimulationIPCClient
def env_ready(sim_id: str) -> bool:
sim_dir = Path(SimulationRunner.RUN_STATE_DIR) / sim_id
return sim_dir.is_dir() and SimulationIPCClient(str(sim_dir)).check_env_alive() Try / catch
try:
SimulationRunner.interview_agent(sim_id, agent_id, prompt)
except ValueError as e:
if "环境未运行" in str(e):
return {"success": False, "retry_after": 5} # client backs off
raise Prevention
- Enable the interview UI only when env liveness is confirmed, not on run creation.
- Retry with backoff through the STARTING window.
- Treat repeated env-death as a crashed run: check env logs before more retries.
When it happens
Trigger: Interviewing while the simulation is still STARTING (env process not yet listening), after the env process has exited/crashed, after the simulation was stopped, or when the IPC socket/pipe in sim_dir is stale from a previous run.
Common situations: Frontend enables the interview panel based on run existence rather than env liveness; polling too early after start; env crashed mid-run while the runner state still says RUNNING.
Related errors
AI-assisted analysis of 666ghj/MiroFish@b5b53acc57 (2026-08-14).
Data as JSON: /api/errors/538768bf86a46230.
Report an issue: GitHub.
Appendix: source
Thrown at backend/app/services/simulation_runner.py:1729
- "reddit": 只采访Reddit平台
- None: 双平台模拟时同时采访两个平台,返回整合结果
timeout: 超时时间(秒)
Returns:
采访结果字典
Raises:
ValueError: 模拟不存在或环境未运行
TimeoutError: 等待响应超时
"""
sim_dir = os.path.join(cls.RUN_STATE_DIR, simulation_id)
if not os.path.exists(sim_dir):
raise ValueError(f"模拟不存在: {simulation_id}")
ipc_client = SimulationIPCClient(sim_dir)
if not ipc_client.check_env_alive():
raise ValueError(f"模拟环境未运行或已关闭,无法执行Interview: {simulation_id}")
logger.info(f"发送Interview命令: simulation_id={simulation_id}, agent_id={agent_id}, platform={platform}")
response = ipc_client.send_interview(
agent_id=agent_id,
prompt=prompt,
platform=platform,
timeout=timeout
)
if response.status.value == "completed":
return {
"success": True,
"agent_id": agent_id,
"prompt": prompt,
"result": response.result,
"timestamp": response.timestamp
}View on GitHub (pinned to b5b53acc57)