mirror of
https://github.com/shareAI-lab/analysis_claude_code.git
synced 2026-05-07 00:36:18 +08:00
Fix: Handle claim_task error response in agent idle loop
This commit is contained in:
@@ -142,6 +142,8 @@ def claim_task(task_id: int, owner: str) -> str:
|
|||||||
if not path.exists():
|
if not path.exists():
|
||||||
return f"Error: Task {task_id} not found"
|
return f"Error: Task {task_id} not found"
|
||||||
task = json.loads(path.read_text())
|
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["owner"] = owner
|
||||||
task["status"] = "in_progress"
|
task["status"] = "in_progress"
|
||||||
path.write_text(json.dumps(task, indent=2))
|
path.write_text(json.dumps(task, indent=2))
|
||||||
@@ -274,7 +276,9 @@ class TeammateManager:
|
|||||||
unclaimed = scan_unclaimed_tasks()
|
unclaimed = scan_unclaimed_tasks()
|
||||||
if unclaimed:
|
if unclaimed:
|
||||||
task = unclaimed[0]
|
task = unclaimed[0]
|
||||||
claim_task(task["id"], name)
|
result = claim_task(task["id"], name)
|
||||||
|
if result.startswith("Error"):
|
||||||
|
continue
|
||||||
task_prompt = (
|
task_prompt = (
|
||||||
f"<auto-claimed>Task #{task['id']}: {task['subject']}\n"
|
f"<auto-claimed>Task #{task['id']}: {task['subject']}\n"
|
||||||
f"{task.get('description', '')}</auto-claimed>"
|
f"{task.get('description', '')}</auto-claimed>"
|
||||||
|
|||||||
Reference in New Issue
Block a user