From 0618ec809ef2b5c98c26b8ab9bce005d6ed75ced Mon Sep 17 00:00:00 2001 From: chablino Date: Mon, 23 Mar 2026 21:42:49 +0800 Subject: [PATCH 1/4] 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 5eabdb91a..59fe3f7ae 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 @@ def _loop(self, name: str, role: str, prompt: str): 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', '')}" From ea53008ae7c9397a487221d8dff17dbe12c3c271 Mon Sep 17 00:00:00 2001 From: to7for <31083461+chablino@users.noreply.github.com> Date: Mon, 23 Mar 2026 22:34:46 +0800 Subject: [PATCH 2/4] Update agents/s11_autonomous_agents.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- agents/s11_autonomous_agents.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/agents/s11_autonomous_agents.py b/agents/s11_autonomous_agents.py index 59fe3f7ae..ac1cd7b4c 100644 --- a/agents/s11_autonomous_agents.py +++ b/agents/s11_autonomous_agents.py @@ -142,8 +142,12 @@ 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" + if task.get("owner"): + existing_owner = task.get("owner") or "someone else" + return f"Error: Task {task_id} has already been claimed by {existing_owner}" + if task.get("status") != "pending": + status = task.get("status") + return f"Error: Task {task_id} cannot be claimed because its status is '{status}'" task["owner"] = owner task["status"] = "in_progress" path.write_text(json.dumps(task, indent=2)) From 644b0753c981b3a25ba0a9338e860c6c94854df5 Mon Sep 17 00:00:00 2001 From: to7for <31083461+chablino@users.noreply.github.com> Date: Mon, 23 Mar 2026 22:34:56 +0800 Subject: [PATCH 3/4] Update agents/s11_autonomous_agents.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- agents/s11_autonomous_agents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agents/s11_autonomous_agents.py b/agents/s11_autonomous_agents.py index ac1cd7b4c..5f1907400 100644 --- a/agents/s11_autonomous_agents.py +++ b/agents/s11_autonomous_agents.py @@ -281,7 +281,7 @@ def _loop(self, name: str, role: str, prompt: str): if unclaimed: task = unclaimed[0] result = claim_task(task["id"], name) - if result.startswith("Error"): + if result.startswith("Error:"): continue task_prompt = ( f"Task #{task['id']}: {task['subject']}\n" From 42fac6af5aea3638bd6840070cd2661e86a7b7a1 Mon Sep 17 00:00:00 2001 From: chablino Date: Mon, 23 Mar 2026 22:42:24 +0800 Subject: [PATCH 4/4] Fix: Add blockedBy check in claim_task to prevent LLM bypassing dependencies --- agents/s11_autonomous_agents.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/agents/s11_autonomous_agents.py b/agents/s11_autonomous_agents.py index 5f1907400..721d04900 100644 --- a/agents/s11_autonomous_agents.py +++ b/agents/s11_autonomous_agents.py @@ -148,6 +148,8 @@ def claim_task(task_id: int, owner: str) -> str: if task.get("status") != "pending": status = task.get("status") return f"Error: Task {task_id} cannot be claimed because its status is '{status}'" + if task.get("blockedBy"): + return f"Error: Task {task_id} is blocked by other task(s) and cannot be claimed yet" task["owner"] = owner task["status"] = "in_progress" path.write_text(json.dumps(task, indent=2))