datawhalechina/hello-agents · error · AgentException
Validator Agent执行失败: {str(e)}
Error message
Validator Agent执行失败: {str(e)} What it means
Catch-all in ValidatorAgent.run wrapping failures of citation generation (_generate_citations across formats like bibtex) or citation verification. The original message rides in the suffix; common roots are paper_info records missing fields a format builder assumes (year, authors, venue) and verification endpoints being unreachable.
Source
Thrown at Co-creation-projects/Apricity-InnocoreAI/agents/validator.py:79
# 4. 缓存结果
await self._cache_citation_results(final_citations)
self.set_state("completed")
return {
"status": "success",
"paper_info": paper_info,
"citations": final_citations,
"verification": verification_result,
"formats_generated": list(citations.keys()),
"verification_status": verification_result.get("status", "unknown"),
"timestamp": datetime.now().isoformat()
}
except Exception as e:
self.set_state("error")
raise AgentException(f"Validator Agent执行失败: {str(e)}")
def get_required_fields(self) -> List[str]:
"""获取必需的输入字段"""
return ["paper_info"]
async def _generate_citations(self, paper_info: Dict, formats: List[str]) -> Dict[str, Any]:
"""生成多种格式的引用"""
citations = {}
for format_type in formats:
try:
if format_type.lower() == "bibtex":
citations["bibtex"] = await self._generate_bibtex_citation(paper_info)
elif format_type.lower() == "apa":
citations["apa"] = await self._generate_apa_citation(paper_info)
elif format_type.lower() == "ieee":
citations["ieee"] = await self._generate_ieee_citation(paper_info)
else:View on GitHub (pinned to 606a07d341)
Solutions
- Check the suffix for the exact field/endpoint that failed and normalize paper_info before calling validator.
- Build paper_info with guaranteed keys: id, title, authors (list of names), year, venue, doi (may be empty).
- Inside _generate_citations, use paper_info.get('year', 'n.d.') style defaults so one missing field degrades that format, not the whole run.
- Re-raise typed exceptions unchanged and add 'from e'.
- Unit-test each citation format against a minimal valid paper_info fixture.
Example fix
# before
except Exception as e:
self.set_state("error")
raise AgentException(f"Validator Agent执行失败: {str(e)}")
# after — normalize input + non-fatal per-format failures
paper_info = {
**raw_info,
"authors": [a if isinstance(a, str) else a.get("name", "") for a in raw_info.get("authors", [])],
"year": raw_info.get("year") or "n.d.",
}
for fmt in formats:
try:
citations[fmt] = build(fmt, paper_info)
except Exception as e: # one bad format never kills the run
logger.warning(f"格式 {fmt} 生成失败: {e}") Defensive patterns
Strategy: validation
Validate before calling
# Normalize paper_info into the shape validator expects before calling
required = {"id", "title", "authors", "year"}
normalized = {
"id": raw.get("id", ""),
"title": raw.get("title", ""),
"authors": [a if isinstance(a, str) else a.get("full_name", a.get("name", ""))
for a in raw.get("authors", [])],
"year": raw.get("year") or (raw.get("published", "")[:4] or "n.d."),
"doi": raw.get("doi", ""),
}
missing = required - {k for k, v in normalized.items() if v}
if missing:
raise ValueError(f"paper_info missing: {sorted(missing)}") Type guard
def is_valid_paper_info(v) -> bool:
return (
isinstance(v, dict)
and isinstance(v.get("title"), str) and v["title"]
and isinstance(v.get("authors"), list)
) Try / catch
try:
result = await validator.run({"paper_info": info})
except AgentException as e:
if "Validator Agent执行失败" in str(e):
logger.error("citation failure: %s", e, exc_info=True)
# citations are additive — fail soft, keep the rest of the workflow
result = {"status": "partial", "citations": {}, "error": str(e)}
else:
raise Prevention
- Normalize author lists (arXiv vs IEEE shapes differ) into plain name strings before validating.
- Default optional fields (year, venue, doi) instead of letting format builders KeyError.
- Treat citation generation as non-fatal in the workflow — degrade per-format, not per-run.
When it happens
Trigger: run({'paper_info': {...}}) where paper_info lacks 'authors' or 'year' so a bibtex/GB/T f-string raises KeyError/AttributeError; DOI-verification HTTP calls failing; paper_info passed as a list or string instead of dict causing type errors in builders.
Common situations: Passing raw arXiv API dicts (IEEE shape differs: authors nested under authors.authors) straight into validator; optional fields never populated for older DB rows; verification service blocked by firewall.
Related errors
- 工具 '{tool_name}' 执行失败: {str(e)}
- Coach Agent执行失败: {str(e)}
- Hunter Agent执行失败: {str(e)}
- Miner Agent执行失败: {str(e)}
- 工具 '{tool_name}' 不存在
AI-assisted analysis of datawhalechina/hello-agents@606a07d341 (2026-08-14).
Data as JSON: /api/errors/fe1216dc4708fc7f.
Report an issue: GitHub.