From 0618ec809ef2b5c98c26b8ab9bce005d6ed75ced Mon Sep 17 00:00:00 2001 From: chablino Date: Mon, 23 Mar 2026 21:42:49 +0800 Subject: [PATCH] Fix: Handle claim_task error response in agent idle loop --- agents/s11_autonomous_agents.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/agents/s11_autonomous_agents.py b/agents/s11_autonomous_agents.py index 5eabdb9..59fe3f7 100644 --- a/agents/s11_autonomous_agents.py +++ b/agents/s11_autonomous_agents.py @@ -142,6 +142,8 @@ def claim_task(task_id: int, owner: str) -> str: if not path.exists(): return f"Error: Task {task_id} not found" task = json.loads(path.read_text()) + if task.get("owner") or task.get("status") != "pending": + return f"Error: Task {task_id} has already been claimed by someone else" task["owner"] = owner task["status"] = "in_progress" path.write_text(json.dumps(task, indent=2)) @@ -274,7 +276,9 @@ class TeammateManager: unclaimed = scan_unclaimed_tasks() if unclaimed: task = unclaimed[0] - claim_task(task["id"], name) + result = claim_task(task["id"], name) + if result.startswith("Error"): + continue task_prompt = ( f"Task #{task['id']}: {task['subject']}\n" f"{task.get('description', '')}"