run_outcome.py 955 B

123456789101112131415161718192021222324252627282930
  1. """判定 find_agent 调度执行是否真正成功完成。"""
  2. from __future__ import annotations
  3. from dataclasses import dataclass
  4. from supply_agent.types import AgentResult
  5. from supply_infra.services.video_discovery_service import get_video_discovery_service
  6. @dataclass(frozen=True)
  7. class FindAgentRunOutcome:
  8. succeeded: bool
  9. failure_reason: str | None = None
  10. def evaluate_find_agent_run(
  11. run_id: str,
  12. agent_result: AgentResult | None = None,
  13. ) -> FindAgentRunOutcome:
  14. """有候选写入即成功:``video_discovery_candidate`` 按 run_id 存在记录。
  15. ``agent_result`` 保留给调用方兼容,不再参与成败判定。
  16. """
  17. del agent_result # 成败只看库表,不看模型最终文案
  18. if get_video_discovery_service().has_candidates(run_id):
  19. return FindAgentRunOutcome(succeeded=True)
  20. return FindAgentRunOutcome(
  21. succeeded=False,
  22. failure_reason="no_candidates",
  23. )