feat: UX Cleanup & Critical TaskBeat Fix

UX Improvements:
- Tasks page: Remove 'Create new task' form (orchestrator handles all)
- Orchestrator: Simplified to single 'Prompt' section, removed 'Tasks verteilen'
- Orchestrator: Removed 'Klassisch senden' button (live-only responses)
- Orchestrator: Removed 'Aktive Agenten' display (redundant with dashboard)

Critical Fix:
- TaskBeat now reads pending tasks from DATABASE instead of in-memory array
- All status updates (pending→in_progress→completed) now persist to DB
- Fixes issue where tasks created via API/UI were not being processed
- Agent_key updates also synced to DB

This fixes the bug where Task #1 was stuck in pending status.
This commit is contained in:
pdyde 2026-02-21 15:04:22 +01:00
parent c949c04a5c
commit 50c1a0315b
3 changed files with 34 additions and 100 deletions

19
app.py
View file

@ -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'])