{"record":{"id":"8b776d05326d32cc","repo":"666ghj/MiroFish","slug":"agent-simulation-id","errorCode":null,"errorMessage":"模拟配置中没有Agent: {simulation_id}","messagePattern":"模拟配置中没有Agent: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/app/services/simulation_runner.py","lineNumber":1855,"sourceCode":"\n        Returns:\n            全局采访结果字典\n        \"\"\"\n        sim_dir = os.path.join(cls.RUN_STATE_DIR, simulation_id)\n        if not os.path.exists(sim_dir):\n            raise ValueError(f\"模拟不存在: {simulation_id}\")\n\n        # 从配置文件获取所有Agent信息\n        config_path = os.path.join(sim_dir, \"simulation_config.json\")\n        if not os.path.exists(config_path):\n            raise ValueError(f\"模拟配置不存在: {simulation_id}\")\n\n        with open(config_path, 'r', encoding='utf-8') as f:\n            config = json.load(f)\n\n        agent_configs = config.get(\"agent_configs\", [])\n        if not agent_configs:\n            raise ValueError(f\"模拟配置中没有Agent: {simulation_id}\")\n\n        # 构建批量采访列表\n        interviews = []\n        for agent_config in agent_configs:\n            agent_id = agent_config.get(\"agent_id\")\n            if agent_id is not None:\n                interviews.append({\n                    \"agent_id\": agent_id,\n                    \"prompt\": prompt\n                })\n\n        logger.info(f\"发送全局Interview命令: simulation_id={simulation_id}, agent_count={len(interviews)}, platform={platform}\")\n\n        return cls.interview_agents_batch(\n            simulation_id=simulation_id,\n            interviews=interviews,\n            platform=platform,\n            timeout=timeout","sourceCodeStart":1837,"sourceCodeEnd":1873,"githubUrl":"https://github.com/666ghj/MiroFish/blob/b5b53acc57189a4a42e44a23e149dc655c98fe82/backend/app/services/simulation_runner.py#L1837-L1873","documentation":"interview_all_agents loads simulation_config.json and reads agent_configs; if the key is absent or the list is empty, there is nothing to interview and it raises ValueError('模拟配置中没有Agent'). Only agents with a non-null agent_id are included, so a config whose agents all lack agent_id also produces an empty list downstream of this check failing first.","triggerScenarios":"Config JSON has \"agent_configs\": [] or omits the key entirely; mis-generated config from the simulation generator; schema drift where the field was renamed.","commonSituations":"Config generator produced an empty agent set (bad profile input); hand-edited configs; older configs written before the agent_configs schema was introduced.","solutions":["Inspect simulation_config.json in the run directory: confirm agent_configs is a non-empty array of objects each carrying agent_id.","Regenerate the simulation config from valid agent profiles and restart the simulation.","If you meant to interview specific agents, use interview_agent/batch_interview with explicit ids instead of the global path."],"exampleFix":"// before\n{ \"simulation_name\": \"demo\", \"agent_configs\": [] }  // 模拟配置中没有Agent\n\n// after\n{ \"simulation_name\": \"demo\", \"agent_configs\": [ { \"agent_id\": \"agent_001\", \"platform\": \"twitter\" }, { \"agent_id\": \"agent_002\", \"platform\": \"reddit\" } ] }","handlingStrategy":"validation","validationCode":"def config_has_agents(sim_id: str) -> bool:\n    cfg_path = Path(SimulationRunner.RUN_STATE_DIR) / sim_id / \"simulation_config.json\"\n    if not cfg_path.is_file():\n        return False\n    agents = json.loads(cfg_path.read_text(encoding=\"utf-8\")).get(\"agent_configs\", [])\n    return any(a.get(\"agent_id\") is not None for a in agents)","typeGuard":"def is_valid_agent_config(cfg: dict) -> bool:\n    return isinstance(cfg.get(\"agent_configs\"), list) and len(cfg[\"agent_configs\"]) > 0 and all(\n        isinstance(a, dict) and a.get(\"agent_id\") for a in cfg[\"agent_configs\"]\n    )","tryCatchPattern":"try:\n    SimulationRunner.interview_all_agents(sim_id, prompt)\nexcept ValueError as e:\n    if \"没有Agent\" in str(e):\n        return {\"success\": False, \"error\": \"empty_agent_config\"}\n    raise","preventionTips":["Validate agent_configs is non-empty with agent_id on every entry during config generation.","Add a schema check to the config-generator's tests.","Refuse to start simulations whose config has zero agents."],"tags":["simulation","global-interview","config-validation","empty-agents"],"backgroundTag":null,"analyzedSha":"b5b53acc57189a4a42e44a23e149dc655c98fe82","analyzedAt":"2026-08-14T22:29:33.146Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}