fix: Handle orchestrated tasks without sub_tasks

Problem:
- Task #1 was stuck in 'in_progress' status
- TaskBeat expects 'sub_tasks' array for orchestrated tasks
- Tasks created via old API didn't have sub_tasks defined
- TaskBeat only processes 'pending' tasks, so in_progress tasks stay stuck

Solution:
- Added validation: if orchestrated task has no sub_tasks, mark as completed with error message
- Prevents infinite loop with stuck tasks
- Manually completed Task #1 in database

Note: This handles legacy tasks from deprecated /api/orchestrate endpoint.
This commit is contained in:
pdyde 2026-02-21 15:44:00 +01:00
parent dc2ea07621
commit d48537b1fd

6
app.py
View file

@ -1909,6 +1909,12 @@ def process_beat_tasks():
sub_tasks = task.get('sub_tasks', []) sub_tasks = task.get('sub_tasks', [])
available_agents = task.get('available_agents', list(AGENTS.keys())) available_agents = task.get('available_agents', list(AGENTS.keys()))
# Falls keine sub_tasks: Task ist fehlerhaft, markiere als completed
if not sub_tasks:
logger.warning("[TaskBeat] Task #%d hat keine sub_tasks - als completed markiert", task['id'])
update_task_db(task['id'], status='completed', response='Fehler: Keine sub_tasks definiert. Dieser Task wurde wahrscheinlich über eine veraltete API erstellt.')
continue
prompt = f"""Du bist der Master-Orchestrator. Analysiere folgende Tasks und weise sie den richtigen Agenten zu: prompt = f"""Du bist der Master-Orchestrator. Analysiere folgende Tasks und weise sie den richtigen Agenten zu:
Tasks: Tasks: