Merge dev to main: Security improvements and comprehensive test infrastructure #39
@@ -225,15 +225,29 @@ async def move_task(
|
||||
print(f"[Move] Task {task_id} not assigned, auto-assigning to PM agent")
|
||||
updates["assigned_to"] = "pm"
|
||||
updates["assigned_type"] = "agent"
|
||||
# Create agent execution record
|
||||
execution_id = await opc_db.create_agent_execution(
|
||||
|
||||
# If assigned to an agent, ensure there's a pending execution
|
||||
if current_task.get("assigned_type") == "agent" or updates.get("assigned_type") == "agent":
|
||||
agent_id = updates.get("assigned_to") or current_task.get("assigned_to")
|
||||
print(f"[Move] Task {task_id} assigned to agent {agent_id}, checking for existing execution")
|
||||
|
||||
# Check if there's already a pending execution
|
||||
existing_executions = await opc_db.get_agent_executions(
|
||||
task_id=task_id,
|
||||
agent_id="pm",
|
||||
actor=user.username
|
||||
status="pending",
|
||||
limit=1
|
||||
)
|
||||
print(f"[Move] Created agent execution {execution_id} for task {task_id}")
|
||||
else:
|
||||
print(f"[Move] Task {task_id} already assigned to {current_task.get('assigned_to')}")
|
||||
|
||||
if not existing_executions:
|
||||
print(f"[Move] No pending execution found, creating one for agent {agent_id}")
|
||||
execution_id = await opc_db.create_agent_execution(
|
||||
task_id=task_id,
|
||||
agent_id=agent_id,
|
||||
actor=user.username
|
||||
)
|
||||
print(f"[Move] Created agent execution {execution_id} for task {task_id}")
|
||||
else:
|
||||
print(f"[Move] Pending execution already exists: {existing_executions[0]['id']}")
|
||||
|
||||
if old_status == "in_progress" and move.status != "in_progress":
|
||||
await opc_db.stop_time_entry(task_id=task_id)
|
||||
|
||||
Reference in New Issue
Block a user