feat: update heartbeat guidelines for agents and leads to clarify task review and commenting rules

This commit is contained in:
Abhimanyu Saharan
2026-02-05 23:27:09 +05:30
parent 51b352df45
commit 5ed6b923a4
3 changed files with 51 additions and 8 deletions

View File

@@ -454,8 +454,8 @@ def update_task(
comment = None
if actor.actor_type == "agent" and actor.agent and actor.agent.is_board_lead:
allowed_fields = {"assigned_agent_id"}
if comment is not None or "status" in updates or not set(updates).issubset(allowed_fields):
allowed_fields = {"assigned_agent_id", "status"}
if comment is not None or not set(updates).issubset(allowed_fields):
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Board leads can only assign or unassign tasks.",
@@ -476,6 +476,22 @@ def update_task(
task.assigned_agent_id = agent.id
else:
task.assigned_agent_id = None
if "status" in updates:
validate_task_status(updates["status"])
if task.status != "review":
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Board leads can only change status when a task is in review.",
)
if updates["status"] not in {"done", "inbox"}:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Board leads can only move review tasks to done or inbox.",
)
if updates["status"] == "inbox":
task.assigned_agent_id = None
task.in_progress_at = None
task.status = updates["status"]
task.updated_at = datetime.utcnow()
session.add(task)
if task.status != previous_status:
@@ -636,10 +652,10 @@ def create_task_comment(
actor: ActorContext = Depends(require_admin_or_agent),
) -> ActivityEvent:
if actor.actor_type == "agent" and actor.agent:
if actor.agent.is_board_lead:
if actor.agent.is_board_lead and task.status != "review":
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Board leads cannot comment on tasks. Delegate to another agent.",
detail="Board leads can only comment during review.",
)
if actor.agent.board_id and task.board_id and actor.agent.board_id != task.board_id:
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN)