()
| 391 | |
| 392 | |
| 393 | def scan_unclaimed_tasks() -> list[dict]: |
| 394 | unclaimed = [] |
| 395 | for f in sorted(TASKS_DIR.glob("task_*.json")): |
| 396 | task = json.loads(f.read_text()) |
| 397 | if (task.get("status") == "pending" |
| 398 | and not task.get("owner") |
| 399 | and can_start(task["id"])): |
| 400 | unclaimed.append(task) |
| 401 | return unclaimed |
| 402 | |
| 403 | |
| 404 | def idle_poll(agent_name: str, messages: list, |