Task Queue Architecture
Overview
The task scheduling system allows users to create recurring or one-time tasks that execute in the background. It uses Google Cloud Tasks for reliable scheduling with Firebase for persistence.
Architecture
User Request
↓
Task Detection (LLM)
↓
┌─────────────────────────────────────────────────────────────────┐
│ TASK CREATION FLOW │
│ │
│ 1. LLM decides: TASK_CREATION / TASK_UPDATE / REFUSAL │
│ 2. Generate task details (title, description, purpose) │
│ 3. Build schedule using LLM + RRULE │
│ 4. Save to Firebase (tasks collection) │
│ 5. Schedule in Google Cloud Tasks │
│ ├─ ≤30 days: Schedule at exact time │
│ └─ >30 days: Schedule "wake-up" in 30 days │
└─────────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────────┐
│ TASK EXECUTION FLOW │
│ │
│ Google Cloud Tasks │
│ ↓ │
│ HTTP POST to /v1/tasks/execute │
│ ↓ │
│ Auth via secret token │
│ ↓ │
│ Reconstruct conversation context │
│ ↓ │
│ Execute via main orchestrator │
│ ↓ │
│ Save result to Firebase (executions subcollection) │
│ ↓ │
│ Schedule next occurrence (recurring tasks) │
└─────────────────────────────────────────────────────────────────┘