6.6 KiB
Multi-Agent Today's Tasks System - Implementation Plan
Date: 2025-03-01 Status: Architecture Plan Target System: Today's Tasks Workflow (Multi-Agent Committee)
📋 Executive Summary
This document outlines the implementation plan for transforming the "Today's Tasks" system from a single-prompt generator into a Multi-Agent "Committee" Architecture.
Instead of a generic LLM generating tasks, we will leverage our existing specialized agents (StrategyArchitect, ContentStrategist, SEOOptimization, etc.) to propose high-value, context-aware tasks based on their specific domain knowledge. A central "Manager" (Orchestrator) will then consolidate, prioritize, and deduplicate these proposals into a cohesive daily plan.
We will also introduce a Self-Learning Task Memory using txtai to ensure the system learns from user behavior (acceptances/rejections) and avoids redundant suggestions.
🏗️ Architecture: The "Committee" Model
1. Agent Roles & Responsibilities
Each agent will act as a "Department Head," submitting daily proposals for their specific pillar.
| Workflow Pillar | Owner Agent | Data Sources | Proposal Type Example |
|---|---|---|---|
| PLAN | StrategyArchitectAgent |
Content Pillars, Strategy Doc | "Review 'AI Trends' pillar strategy - engagement dropped 10%." |
| GENERATE | ContentStrategyAgent |
Content Gaps, Trends | "Draft a blog post on 'Vector Search' (High Opportunity Gap)." |
| PUBLISH | SocialAmplificationAgent |
Audience Activity, Calendar | "Schedule your 'Weekly Recap' thread for 10 AM (Peak Audience)." |
| ANALYZE | SEOOptimizationAgent |
GSC, Site Health, Rankings | "Fix 3 broken links on your pricing page to recover link equity." |
| ENGAGE | SocialAmplificationAgent |
Social Mentions, Comments | "Reply to 3 unanswered comments on your latest LinkedIn post." |
| REMARKET | CompetitorResponseAgent |
Competitor Activity | "Competitor X posted about [Topic]. Create a counter-narrative Reel." |
2. The Workflow (Daily Cycle)
- Morning Briefing (Parallel):
TodayWorkflowManagerpolls all agents viapropose_daily_tasks(context). - Aggregation: Manager collects raw proposals (~10-15 tasks).
- Intelligence Filter (Self-Learning):
- Check
TaskMemoryIndex(txtai). - Filter out tasks similar to previously Rejected tasks.
- Deprioritize tasks similar to recently Completed tasks.
- Check
- Consolidation: Deduplicate overlapping ideas (e.g., SEO & Content agents both suggesting the same topic).
- Final Selection: Select top 1-3 tasks per pillar based on user goals (e.g., "Growth" mode = more Publish/Remarket tasks).
🚀 Implementation Phases
Phase 1: Agent Interface Standardization (The "Voice")
Objective: Give every agent the ability to speak the "Task Proposal" language. Status: ✅ Completed
- Task 1.1: Define
TaskProposalschema (Pydantic model). ✅- Fields:
title,description,pillar,priority,reasoning,estimated_time,action_type.
- Fields:
- Task 1.2: Update
BaseALwrityAgentwith abstractpropose_daily_tasks(context: Dict) -> List[TaskProposal]. ✅ - Task 1.3: Implement
propose_daily_tasksin all specialized agents. ✅- StrategyArchitect: Logic to check pillar health.
- ContentStrategist: Logic to check content gaps.
- SEOAgent: Logic to check GSC alerts/errors.
- SocialAmplification: Logic for publish/engage.
- CompetitorResponse: Logic for monitoring.
Phase 2: The Manager (The "Orchestrator")
Objective: Build the backend service that coordinates the committee. Status: ✅ Completed
- Task 2.1: Refactor
TodayWorkflowGeneratorintoday_workflow_service.py. ✅- Replace single-prompt generation with
gather_agent_proposals(). - Implement
asyncio.gatherfor parallel agent execution (performance critical).
- Replace single-prompt generation with
- Task 2.2: Implement
consolidate_proposals()logic. ✅- Use a lightweight LLM call to merge/rank the raw list if needed, or deterministic logic for speed.
- Task 2.3: Connect to Frontend. ✅
- Ensure the API response matches the existing
TodayTaskfrontend interface.
- Ensure the API response matches the existing
Phase 3: Self-Learning Memory (The "Brain")
Objective: Stop the system from nagging users about things they hate or just did. Status: ✅ Completed
- Task 3.1: Create
TaskHistorymodel in DB. ✅- Store:
task_vector_id,original_text,status(completed/rejected/skipped),user_feedback.
- Store:
- Task 3.2: Implement
TaskMemoryServiceusingtxtai. ✅- Index tasks with metadata.
- Implement
is_redundant_or_rejected(proposal_text)check.
- Task 3.3: Wire feedback loop. ✅
- When user clicks "Dismiss" or "Complete" in frontend, update the
txtaiindex.
- When user clicks "Dismiss" or "Complete" in frontend, update the
Phase 4: UI Feedback & Transparency
Objective: Show the user why a task was suggested.
- Task 4.1: Update Frontend
TodayTaskcard.- Add "Suggested by [Agent Name]" badge.
- Add "Why?" tooltip (e.g., "Because Competitor X did Y").
- Task 4.2: Add "Train my Agents" feedback.
- "Don't show this again" vs "Not today".
📊 Data Models
1. TaskProposal (Backend)
class TaskProposal(BaseModel):
title: str
description: str
pillar_id: str # plan, generate, publish, analyze, engage, remarket
priority: str # high, medium, low
estimated_time: int # minutes
source_agent: str # e.g., "SEOOptimizationAgent"
reasoning: str # "Detected 404 error spike"
context_data: Optional[Dict] # e.g., {"url": "..."}
2. TaskMemoryDocument (txtai)
{
"id": "uuid",
"text": "Write a blog post about AI Trends",
"embedding": [vector],
"tags": ["generate", "content_strategy"],
"user_id": "123",
"status": "rejected",
"last_updated": "2024-03-01T10:00:00Z"
}
🛠️ Technical Considerations
- Performance: Calling 6 agents + LLMs in parallel can be slow.
- Mitigation: Set strict timeouts (e.g., 5s) per agent. Use "Lite" logic for proposals (e.g., check DB/Cache instead of live crawling) where possible.
- Fallback: If agents time out or fail, fall back to the
_fallback_taskstemplate currently in place. - Token Usage: Summarize context before sending to agents to minimize input tokens.
📅 Execution Timeline
- Day 1: Phase 1 (Interfaces & 2 core agents).
- Day 2: Phase 2 (Orchestrator wiring).
- Day 3: Phase 3 (txtai Memory integration).
- Day 4: Phase 1 completion (remaining agents) & Phase 4 (UI polish).