From 7c0eefbba3d317e961216da9a03b54bbe67234a5 Mon Sep 17 00:00:00 2001 From: Jarvis Date: Mon, 2 Feb 2026 17:47:52 +0000 Subject: [PATCH] Dispatch review tasks to reviewer (not assignee) --- backend/app/api/work.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/backend/app/api/work.py b/backend/app/api/work.py index d6dde50a..41b8ef5f 100644 --- a/backend/app/api/work.py +++ b/backend/app/api/work.py @@ -137,11 +137,24 @@ def dispatch_task( detail="OpenClaw gateway is not configured (set OPENCLAW_GATEWAY_URL/TOKEN)", ) - # Best-effort: enqueue an agent dispatch. This does not mutate the task. - background.add_task( - notify_openclaw, - NotifyContext(event="task.assigned", actor_employee_id=actor_employee_id, task_id=task.id), - ) + # Best-effort: enqueue a dispatch notification. + # IMPORTANT: if a task is already in review, the reviewer (not the assignee) should be notified. + status = (getattr(task, "status", None) or "").lower() + if status in {"review", "ready_for_review"}: + background.add_task( + notify_openclaw, + NotifyContext( + event="status.changed", + actor_employee_id=actor_employee_id, + task_id=task.id, + changed_fields={"status": {"to": task.status}}, + ), + ) + else: + background.add_task( + notify_openclaw, + NotifyContext(event="task.assigned", actor_employee_id=actor_employee_id, task_id=task.id), + ) return {"ok": True}