datawhalechina/hello-agents · error · AgentException
论文不存在: {paper_id}
Error message
论文不存在: {paper_id} What it means
Guard in MinerAgent.run: after db_manager.get_paper(paper_id) returns falsy, the agent refuses to analyze. The paper must already exist in the local database — normally inserted by the Hunter stage — so this fires when analysis is requested for an ID that was never hunted/downloaded, belongs to another user, or after the DB was reset.
Source
Thrown at Co-creation-projects/Apricity-InnocoreAI/agents/miner.py:43
self.add_tool("search_memory", self._search_memory, "搜索记忆库")
self.add_tool("compare_papers", self._compare_papers, "对比论文")
self.add_tool("generate_report", self._generate_report, "生成分析报告")
async def run(self, input_data: Dict[str, Any]) -> Dict[str, Any]:
"""执行论文分析和创新点挖掘任务"""
await self.validate_input(input_data)
self.set_state("running")
try:
paper_id = input_data["paper_id"]
user_id = input_data.get("user_id")
analysis_type = input_data.get("analysis_type", "full") # full, quick, innovation_only
# 获取论文信息
paper = await db_manager.get_paper(paper_id)
if not paper:
raise AgentException(f"论文不存在: {paper_id}")
self._add_to_history(f"开始分析论文: {paper['title']}")
# 1. 解析PDF内容
parsed_content = await self._parse_paper_content(paper)
# 2. 检索相关历史论文
related_papers = await self._find_related_papers(
paper["title"],
paper["abstract"],
user_id
)
# 3. 进行对比分析
comparison_result = await self._perform_comparison_analysis(
parsed_content,
related_papers
)View on GitHub (pinned to 606a07d341)
Solutions
- Confirm the ID exists: query the papers table (or GET /papers) and use the exact stored id value.
- Run the hunting step first so the paper is persisted before invoking miner.
- Normalize IDs at insert time (strip URL prefixes, store one canonical form) so producers and consumers agree.
- If multi-user, pass the same user_id used during hunting so get_paper's scope matches.
- Return the list of valid ids in the error to speed up debugging.
Example fix
# before
paper = await db_manager.get_paper(paper_id)
if not paper:
raise AgentException(f"论文不存在: {paper_id}")
# after — helpful error with lookup hints
paper = await db_manager.get_paper(paper_id)
if not paper:
count = await db_manager.count_papers()
raise AgentException(
f"论文不存在: {paper_id} (库中共 {count} 篇; 请先运行 Hunter 抓取, 并使用其返回的 id)"
) Defensive patterns
Strategy: validation
Validate before calling
# Verify the paper exists before invoking the miner
paper = await db_manager.get_paper(paper_id)
if paper is None:
available = await db_manager.list_paper_ids(limit=20)
raise ValueError(
f"paper {paper_id!r} not found; run Hunter first. "
f"Sample ids: {available}"
) Type guard
async def paper_exists(paper_id: str) -> bool:
return (await db_manager.get_paper(paper_id)) is not None Try / catch
try:
result = await miner.run({"paper_id": pid})
except AgentException as e:
if "论文不存在" in str(e):
new_id = await hunt_and_store(pid) # fetch + persist, then retry once
result = await miner.run({"paper_id": new_id})
else:
raise Prevention
- Always mine with the exact id returned by the hunter stage.
- Normalize external ids (strip URLs, one canonical form) at insert time.
- In full workflows, skip analysis when the hunt stage found zero papers.
When it happens
Trigger: Calling miner.run({'paper_id':'1234.5678'}) with an arXiv ID string when the DB stores a different key format; running FULL_WORKFLOW where hunting found zero papers and a stale ID is passed downstream; analysis request for a paper_id saved under a different user_id scope; dev DB wiped between hunt and mine steps.
Common situations: Frontend sending the arXiv canonical id (entry.id URL tail) while hunter stored article_number; multi-user filtering in get_paper; separate containers pointing at different database files; race where analysis is requested before hunt transaction commits.
Related errors
- 工具 '{tool_name}' 不存在
- 缺少必需字段: {field}
- 不支持的任务类型: {task_type}
- 工具 '{tool_name}' 执行超时
- 工具 '{tool_name}' 执行失败: {str(e)}
AI-assisted analysis of datawhalechina/hello-agents@606a07d341 (2026-08-14).
Data as JSON: /api/errors/c30598b5a23e4aff.
Report an issue: GitHub.