diff --git a/src/daemon/ticker.py b/src/daemon/ticker.py index 50c4b87..20ef4a6 100644 --- a/src/daemon/ticker.py +++ b/src/daemon/ticker.py @@ -496,12 +496,22 @@ class Ticker: try: conn = get_connection(db_path) try: - row = conn.execute( - "SELECT COUNT(*) as cnt FROM routing_decisions " - "WHERE task_id=? AND outcome='dispatched' " - "AND created_at > datetime('now', '-5 minutes')", - (task_id,), - ).fetchone() + # 检查是否有 from_status=review 的 dispatched 记录(防止重复 review dispatch) + if action_type == "review": + row = conn.execute( + "SELECT COUNT(*) as cnt FROM routing_decisions " + "WHERE task_id=? AND outcome='dispatched' " + "AND from_status='review' " + "AND created_at > datetime('now', '-5 minutes')", + (task_id,), + ).fetchone() + else: + row = conn.execute( + "SELECT COUNT(*) as cnt FROM routing_decisions " + "WHERE task_id=? AND outcome='dispatched' " + "AND created_at > datetime('now', '-5 minutes')", + (task_id,), + ).fetchone() return row["cnt"] > 0 if row else False finally: conn.close()