datawhalechina/hello-agents · error · HTTPException

工作流执行失败: {str(e)}

Error message

工作流执行失败: {str(e)}

What it means

Catch-all HTTPException 500 '工作流执行失败: {str(e)}' at api/routes/workflow.py:231 wrapping the entire full-workflow run. Any step failure (search, analysis, writing, citation) after the per-step handling — or a failure in assembling the final results dict — bubbles to this handler, which correctly re-raises HTTPException first but wraps everything else.

Source

Thrown at Co-creation-projects/Apricity-InnocoreAI/api/routes/workflow.py:231

                })
        
        # 完成工作流
        results["status"] = "completed"
        results["summary"] = {
            "total_papers": len(papers),
            "analyzed_papers": len(analyses),
            "generated_citations": len(citations),
            "keywords": request.keywords
        }
        
        logger.info(f"[工作流 {workflow_id}] 完成")
        return results
        
    except HTTPException:
        raise
    except Exception as e:
        logger.error(f"工作流执行失败: {str(e)}")
        raise HTTPException(status_code=500, detail=f"工作流执行失败: {str(e)}")

@router.post("/search-and-analyze", response_model=Dict[str, Any])
async def search_and_analyze(request: WorkflowRequest):
    """
    简化工作流:搜索 + 分析
    只执行搜索和分析步骤
    """
    try:
        results = {
            "status": "running",
            "steps": []
        }
        
        # 步骤 1: 搜索论文
        from api.routes.papers import search_papers, PaperSearchRequest
        
        search_result = await search_papers(PaperSearchRequest(
            keywords=request.keywords,

View on GitHub (pinned to 606a07d341)

Solutions

  1. Read the '工作流执行失败' log with traceback to identify the failing step.
  2. Run the failing step standalone (e.g. POST /workflow/search-and-analyze) to isolate it.
  3. Check LLM/search API keys, quota, and network egress.
  4. Give each step the same try/except+record pattern as step 1 so partial results return with status='failed' instead of an opaque 500.

Example fix

// before
except Exception as e:
    logger.error(f"工作流执行失败: {str(e)}")
    raise HTTPException(status_code=500, detail=f"工作流执行失败: {str(e)}")
// after
except Exception as e:
    logger.exception("工作流执行失败")
    results["status"] = "failed"
    results["error"] = "工作流执行失败"
    return results
Defensive patterns

Strategy: retry

Try / catch

try:
    results = await client.post("/workflow/full", json=payload, timeout=900).json()
except httpx.TimeoutException:
    # fall back to submit + poll pattern
    raise
if results.get("status") == "failed" or client_last_status >= 500:
    identify_failed_step(results); retry_with_wider_keywords()

Prevention

When it happens

Trigger: POST /workflow/full where a later step (writing/review/citation) throws unexpectedly; result aggregation raising (len() on None, missing keys); cancellation of the request mid-workflow.

Common situations: LLM API quota exhausted mid-run; partial pipeline state after an earlier soft-failed step; long runs hitting proxy timeouts that surface as client-side aborts then server-side errors.

Related errors


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