datawhalechina/hello-agents · error · AgentException

Hunter Agent执行失败: {str(e)}

Error message

Hunter Agent执行失败: {str(e)}

What it means

Catch-all in HunterAgent.run: failures from the arXiv/IEEE search helpers, filtering, or PDF download steps are re-wrapped with the 'Hunter Agent执行失败:' prefix after setting agent state to 'error'. The original message is preserved, so typical suffixes are 'ArXiv API请求失败: 403' (error 55), 'IEEE API请求失败: 401' (error 56), or download filesystem errors.

Source

Thrown at Co-creation-projects/Apricity-InnocoreAI/agents/hunter.py:88

                    if downloaded_paper:
                        downloaded_papers.append(downloaded_paper)
                except Exception as e:
                    self._add_to_history(f"下载论文失败 {paper.get('title', 'Unknown')}: {str(e)}")
            
            self.set_state("completed")
            
            return {
                "status": "success",
                "total_found": len(all_papers),
                "unique_papers": len(unique_papers),
                "filtered_papers": len(filtered_papers),
                "downloaded_papers": len(downloaded_papers),
                "papers": downloaded_papers
            }
            
        except Exception as e:
            self.set_state("error")
            raise AgentException(f"Hunter Agent执行失败: {str(e)}")
    
    def get_required_fields(self) -> List[str]:
        """获取必需的输入字段"""
        return ["keywords"]
    
    async def _search_papers_from_arxiv(self, keywords: List[str], max_papers: int, days_back: int) -> List[Dict]:
        """从ArXiv搜索论文"""
        papers = []
        
        # 构建查询字符串
        query_parts = []
        for keyword in keywords:
            query_parts.append(f'all:"{keyword}"')
        query = " OR ".join(query_parts)
        
        # 添加时间过滤
        date_filter = ""
        if days_back > 0:

View on GitHub (pinned to 606a07d341)

Solutions

  1. Read the suffix — it names the failing source and HTTP status; fix that (key, quota, path) rather than the wrapper.
  2. Set the IEEE key in config or exclude 'ieee' from search sources; arXiv alone needs no key.
  3. Pre-create the PDF download directory and verify write permissions.
  4. Space out arXiv calls (their guideline is ~1 request/3s) or cache responses.
  5. Re-raise typed exceptions unchanged (except ExternalAPIException: raise) for cleaner upstream handling.

Example fix

# before
except Exception as e:
    self.set_state("error")
    raise AgentException(f"Hunter Agent执行失败: {str(e)}")

# after
except ExternalAPIException:
    self.set_state("error")
    raise
except Exception as e:
    self.set_state("error")
    raise AgentException(f"Hunter Agent执行失败: {e}") from e
Defensive patterns

Strategy: try-catch

Validate before calling

# Pre-flight the hunter's external dependencies
required_paths = [hunter.download_dir]
for p in required_paths:
    Path(p).mkdir(parents=True, exist_ok=True)
if "ieee" in sources and not config.ieee_api_key:
    sources.remove("ieee")  # skip a source that is guaranteed to 401

Try / catch

try:
    result = await hunter.run({"keywords": kws})
except AgentException as e:
    root = str(e).replace("Hunter Agent执行失败: ", "")
    if "ArXiv" in root or "IEEE" in root:
        result = await hunter.run({"keywords": kws}, sources=["arxiv"])  # degrade to keyless source
    else:
        raise

Prevention

When it happens

Trigger: run({'keywords':[...]}) where arXiv returns non-200 (rate limit / block), the IEEE key is missing so config.ieee_api_key is '' and the API rejects, or the download directory is unwritable when saving PDFs.

Common situations: Missing IEEE_API_KEY in .env but IEEE included in sources; arXiv throttling burst searches from one IP; PDF save path not created at startup; proxy required but unset in the container.

Related errors


AI-assisted analysis of datawhalechina/hello-agents@606a07d341 (2026-08-14). Data as JSON: /api/errors/ccd9244cd7e6300f. Report an issue: GitHub.