{"record":{"id":"94ee63b336e1354e","repo":"666ghj/MiroFish","slug":"zep-error","errorCode":null,"errorMessage":"Zep图谱写入未完整完成: {error}","messagePattern":"Zep图谱写入未完整完成: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"backend/app/services/simulation_runner.py","lineNumber":1062,"sourceCode":"            with cls._finalization_lock(simulation_id):\n                state = cls.get_run_state(simulation_id) or state\n                if cls._graph_memory_enabled.get(simulation_id, False):\n                    try:\n                        ZepGraphMemoryManager.stop_updater(simulation_id)\n                        cls._graph_memory_enabled.pop(simulation_id, None)\n                    except Exception as error:\n                        state.runner_status = RunnerStatus.FAILED\n                        state.twitter_running = False\n                        state.reddit_running = False\n                        state.completed_at = datetime.now().isoformat()\n                        state.error = f\"Zep图谱写入未完整完成: {error}\"\n                        cls._save_run_state(state)\n                        cls._sync_simulation_status(\n                            simulation_id,\n                            RunnerStatus.FAILED,\n                            state.error,\n                        )\n                        raise RuntimeError(state.error) from error\n                state.runner_status = RunnerStatus.STOPPED\n                state.twitter_running = False\n                state.reddit_running = False\n                state.completed_at = datetime.now().isoformat()\n                state.error = None\n                cls._save_run_state(state)\n                cls._sync_simulation_status(\n                    simulation_id,\n                    RunnerStatus.STOPPED,\n                )\n                cls._manual_stop_requests.discard(simulation_id)\n\n        state = cls.get_run_state(simulation_id) or state\n        if state.runner_status == RunnerStatus.FAILED:\n            raise RuntimeError(state.error or \"模拟停止失败\")\n        if state.runner_status != RunnerStatus.STOPPED:\n            raise RuntimeError(\n                f\"模拟停止未达到终态: {simulation_id}, status={state.runner_status}\"","sourceCodeStart":1044,"sourceCodeEnd":1080,"githubUrl":"https://github.com/666ghj/MiroFish/blob/b5b53acc57189a4a42e44a23e149dc655c98fe82/backend/app/services/simulation_runner.py#L1044-L1080","documentation":"RuntimeError raised in the synchronous stop path (no monitor thread) when stopping the Zep graph-memory updater (ZepGraphMemoryManager.stop_updater) throws — e.g. the worker failed batches or timed out. The run is marked FAILED with this composed error, state is persisted, and the original exception is chained with 'from error'.","triggerScenarios":"stop_simulation on a graph-memory-enabled run without a monitor thread; ZepGraphMemoryManager.stop_updater raises TimeoutError ('worker did not stop') or RuntimeError ('N batch(es) failed'); the error string of that exception is embedded into 'Zep图谱写入未完整完成: ...'.","commonSituations":"Zep API outage or auth failure during the final flush at stop time; restart-recovery path or tests that stop a simulation synchronously while ingestion is still pending.","solutions":["Inspect the embedded cause after the colon — it is the underlying Zep failure (timeout vs failed batches) and dictates the fix.","Verify ZEP_API_KEY validity and Zep API reachability, then retry: the graph may be partially ingested, so re-run or re-ingest the missing activity batches.","If this recurs, increase ZEP_INGESTION_WAIT_TIMEOUT_SECONDS and check for network proxies/rate limits between backend and Zep Cloud."],"exampleFix":"// before\nSimulationRunner.stop_simulation(sim_id);  # RuntimeError: Zep图谱写入未完整完成: 3 Zep activity batch(es) failed ...\n\n// after\ntry:\n    SimulationRunner.stop_simulation(sim_id)\nexcept RuntimeError as e:\n    if not str(e).startswith(\"Zep图谱写入未完整完成\"):\n        raise\n    logger.warning(f\"graph ingestion incomplete for {sim_id}: {e}; scheduling re-ingest\")\n    schedule_reingest(sim_id);  # replay actions.jsonl batches into Zep","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    SimulationRunner.stop_simulation(sim_id)\nexcept RuntimeError as e:\n    if not str(e).startswith(\"Zep图谱写入未完整完成\"):\n        raise\n    log_graph_incomplete(sim_id, str(e))  # quarantine + re-ingest workflow\n    state = SimulationRunner.get_run_state(sim_id)  # FAILED; record artifacts","preventionTips":["Verify Zep API health and ZEP_API_KEY before stopping graph-memory runs.","Monitor failed-batch counters during the run, not only at stop.","Keep actions.jsonl until graph ingestion is confirmed complete so replay is possible."],"tags":["simulation","stop","zep","graph-memory","data-loss","partial-write"],"backgroundTag":null,"analyzedSha":"b5b53acc57189a4a42e44a23e149dc655c98fe82","analyzedAt":"2026-08-14T22:29:33.146Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}