{"record":{"id":"f3c1dab17b7d9157","repo":"datawhalechina/hello-agents","slug":"miner-agent-str-e","errorCode":null,"errorMessage":"Miner Agent执行失败: {str(e)}","messagePattern":"Miner Agent执行失败: (.+?)","errorType":"exception","errorClass":"AgentException","httpStatus":500,"severity":"error","filePath":"Co-creation-projects/Apricity-InnocoreAI/agents/miner.py","lineNumber":100,"sourceCode":"                \"paper_id\": paper_id,\n                \"report_id\": report_id,\n                \"analysis_type\": analysis_type,\n                \"parsed_content\": {\n                    \"sections\": list(parsed_content.get(\"sections\", {}).keys()),\n                    \"word_count\": parsed_content.get(\"word_count\", 0)\n                },\n                \"related_papers_count\": len(related_papers),\n                \"report_summary\": {\n                    \"summary\": report.get(\"summary\", \"\")[:200] + \"...\",\n                    \"innovation_points\": len(report.get(\"innovation_points\", [])),\n                    \"limitations\": len(report.get(\"limitations\", [])),\n                    \"future_ideas\": len(report.get(\"future_ideas\", []))\n                }\n            }\n            \n        except Exception as e:\n            self.set_state(\"error\")\n            raise AgentException(f\"Miner Agent执行失败: {str(e)}\")\n    \n    def get_required_fields(self) -> List[str]:\n        \"\"\"获取必需的输入字段\"\"\"\n        return [\"paper_id\"]\n    \n    async def _parse_paper_content(self, paper: Dict) -> Dict[str, Any]:\n        \"\"\"解析论文内容\"\"\"\n        file_path = paper.get(\"file_path\")\n        if not file_path:\n            # 如果没有PDF文件，使用标题和摘要\n            return {\n                \"title\": paper.get(\"title\", \"\"),\n                \"abstract\": paper.get(\"abstract\", \"\"),\n                \"sections\": {\n                    \"abstract\": paper.get(\"abstract\", \"\"),\n                    \"introduction\": \"\",\n                    \"method\": \"\",\n                    \"experiment\": \"\",","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/datawhalechina/hello-agents/blob/606a07d341a47be773fab7f4b71177f53f96b2c3/Co-creation-projects/Apricity-InnocoreAI/agents/miner.py#L82-L118","documentation":"Catch-all in MinerAgent.run wrapping any failure of the analysis pipeline: PDF parsing (_parse_paper_content), related-paper retrieval, LLM analysis via think(), or the earlier get_paper lookup (error 57 emerges with this prefix). State flips to 'error' and the original message is preserved in the suffix, which is where diagnosis should focus.","triggerScenarios":"run({'paper_id':...}) where the stored file_path points to a missing/corrupt PDF (parse error); think() timing out on long abstracts (error 46); db errors in _find_related_papers; paper record lacking abstract so downstream indexing fails.","commonSituations":"PDFs deleted from disk but rows kept in DB; encrypted/scanned PDFs yielding no text; LLM quota exhausted mid-workflow; DB schema migrations dropping fields the miner reads.","solutions":["Read the suffix to identify the stage (parse / related-papers / LLM) and fix that root cause.","Verify the paper's file_path exists and the file is a text-extractable PDF before running analysis.","Guard optional record fields with .get() defaults so missing abstracts don't crash retrieval.","Re-raise typed AgentException/TimeoutException unchanged to avoid double prefixes.","Use raise ... from e for traceable logs."],"exampleFix":"# before\nexcept Exception as e:\n    self.set_state(\"error\")\n    raise AgentException(f\"Miner Agent执行失败: {str(e)}\")\n\n# after\nexcept (AgentException, TimeoutException):\n    self.set_state(\"error\")\n    raise\nexcept Exception as e:\n    self.set_state(\"error\")\n    raise AgentException(f\"Miner Agent执行失败: {e}\") from e","handlingStrategy":"try-catch","validationCode":"# Pre-flight the paper's assets before analysis\nimport os\nif paper.get(\"file_path\") and not os.path.isfile(paper[\"file_path\"]):\n    logger.warning(\"PDF missing on disk; analysis will use title+abstract only\")\nif not (paper.get(\"abstract\") or paper.get(\"file_path\")):\n    raise ValueError(\"paper has neither abstract nor PDF — nothing to analyze\")","typeGuard":null,"tryCatchPattern":"try:\n    report = await miner.run({\"paper_id\": pid})\nexcept AgentException as e:\n    root = str(e).replace(\"Miner Agent执行失败: \", \"\")\n    if \"LLM思考超时\" in root:\n        report = await miner.run({\"paper_id\": pid, \"analysis_type\": \"quick\"})  # cheaper path\n    else:\n        raise","preventionTips":["Check file_path existence and abstract presence before running analysis.","Prefer 'quick' analysis_type for large PDFs or slow LLM endpoints.","Diagnose the suffix (parse/LLM/DB) instead of the wrapper prefix."],"tags":["python","agent","error-wrapping","pdf","analysis"],"backgroundTag":null,"analyzedSha":"606a07d341a47be773fab7f4b71177f53f96b2c3","analyzedAt":"2026-08-14T22:57:27.446Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}