diff --git a/app.py b/app.py index 3d67b78..fce9e54 100644 --- a/app.py +++ b/app.py @@ -1889,12 +1889,20 @@ def process_beat_tasks(): while True: try: - pending_tasks = [t for t in tasks if t.get('status') == 'pending' and t.get('type') in ('agent_created', 'manual', 'orchestrated', 'agent_delegated')] + # Lade pending Tasks aus Datenbank + db_tasks = get_tasks(status='pending') + # Konvertiere zu Dict-Format für Legacy-Kompatibilität + pending_tasks = [] + for db_task in db_tasks: + if db_task.get('type') in ('agent_created', 'manual', 'orchestrated', 'agent_delegated', 'telegram'): + pending_tasks.append(db_task) for task in pending_tasks: agent_key = task.get('agent_key') or task.get('assigned_agent', '') if task.get('agent_key') == 'orchestrator': + # Update in DB + update_task_db(task['id'], status='in_progress') task['status'] = 'in_progress' logger.info("[TaskBeat] Planungsphase für Task #%d", task['id']) @@ -1953,6 +1961,8 @@ Arbeite diesen Teil ab und liefere ein vollständiges Ergebnis.""", created_sub_tasks.append(sub_task_id) logger.info("[TaskBeat] Sub-Task #%d zugewiesen an %s", sub_task_id, assigned) + # Update in DB + update_task_db(task['id'], status='completed') task['status'] = 'completed' task['sub_task_ids'] = created_sub_tasks logger.info("[TaskBeat] Planungs-Task #%d abgeschlossen. %d Sub-Tasks erstellt.", task['id'], len(created_sub_tasks)) @@ -1963,13 +1973,18 @@ Arbeite diesen Teil ab und liefere ein vollständiges Ergebnis.""", if available_agents: agent_key = available_agents[0] task['agent_key'] = agent_key + update_task_db(task['id'], agent_key=agent_key) if agent_key and agent_key in AGENTS: + # Update in DB + update_task_db(task['id'], status='in_progress') task['status'] = 'in_progress' logger.info("[TaskBeat] Verarbeite Task #%d – Agent: %s", task['id'], agent_key) response = execute_agent_task(agent_key, task.get('title', '') + '\n\n' + task.get('description', '')) + # Update in DB + update_task_db(task['id'], response=response) task['response'] = response # Neues Memory-System: Task als strukturierte Erinnerung speichern @@ -1988,6 +2003,8 @@ Arbeite diesen Teil ab und liefere ein vollständiges Ergebnis.""", except Exception as e: logger.warning("[TaskBeat] Konnte Erinnerung nicht speichern: %s", str(e)) + # Update in DB + update_task_db(task['id'], status='completed') task['status'] = 'completed' logger.info("[TaskBeat] Task #%d abgeschlossen.", task['id']) diff --git a/templates/orchestrator.html b/templates/orchestrator.html index 0149a3d..301f532 100644 --- a/templates/orchestrator.html +++ b/templates/orchestrator.html @@ -16,63 +16,23 @@
+ Der Orchestrator analysiert deine Anfrage und delegiert automatisch an die passenden Agenten. +
- Tasks werden automatisch alle 10 Sekunden vom TaskBeat verarbeitet.
-
Diese Seite aktualisiert sich automatisch alle 15 Sekunden wenn Tasks aktiv sind.
-