Summary
Port the task scheduler from gaia6 so agents can create and manage recurring tasks. The Agent UI backend manages asyncio timers — no OS cron, no external scheduler. The agent creates schedules through the Agent UI MCP Server.
Source Spec
docs/plans/autonomous-agent-infrastructure.md — Milestone 5
Source Code (gaia6)
src/gaia/ui/scheduler.py (~1,217 lines) — Async timer manager
src/gaia/ui/routers/schedules.py (~238 lines) — REST API endpoints
src/gaia/apps/webui/src/stores/scheduleStore.ts (~120 lines) — Frontend state
How It Works
User: "Check for trends every morning and suggest posts"
Agent: → schedule_task("morning_trends", "every 24h", "Search for trending AI topics...")
→ Agent UI MCP tool → REST API → scheduler creates asyncio timer
→ Timer fires → creates session → sends prompt through agent → stores result
→ User sees results next time they open a session
MCP Tools (added to Agent UI MCP Server)
schedule_task(name, interval, prompt) — Create recurring task
list_schedules() — List all tasks with status, next run, last result
cancel_schedule(name) — Cancel a task
pause_schedule(name) / resume_schedule(name) — Pause/resume
get_schedule_results(name, limit) — View past run results
Interval Parsing
Supports: "every 30m", "every 6h", "every 24h", "daily at 9am", "every monday at 3pm", "hourly", "weekly"
REST API
POST /api/schedules — Create scheduled task
GET /api/schedules — List all tasks
PUT /api/schedules/{name} — Update (pause/resume/cancel)
GET /api/schedules/{name}/results — Past run results
DELETE /api/schedules/{name} — Delete task
Database
CREATE TABLE scheduled_tasks (
id TEXT PRIMARY KEY,
name TEXT UNIQUE NOT NULL,
interval_seconds INTEGER NOT NULL,
prompt TEXT NOT NULL,
status TEXT DEFAULT 'active', -- active | paused | cancelled
created_at TEXT,
last_run_at TEXT,
next_run_at TEXT,
last_result TEXT -- JSON: {success, summary, timestamp}
);
Proactive Recall
When user starts a new session, agent checks for pending scheduled results and surfaces them: "While you were away, I ran morning_trends and found..."
Dependencies
- Agent UI MCP Server (this milestone)
- MemoryMixin (scheduled tasks use agent memory for context)
Files
src/gaia/ui/scheduler.py # Port from gaia6
src/gaia/ui/routers/schedules.py # Port from gaia6
src/gaia/apps/webui/src/stores/scheduleStore.ts # Port from gaia6
tests/unit/test_scheduler.py
tests/unit/test_scheduler_api.py
tests/integration/test_scheduler_e2e.py
Acceptance Criteria
Summary
Port the task scheduler from gaia6 so agents can create and manage recurring tasks. The Agent UI backend manages asyncio timers — no OS cron, no external scheduler. The agent creates schedules through the Agent UI MCP Server.
Source Spec
docs/plans/autonomous-agent-infrastructure.md— Milestone 5Source Code (gaia6)
src/gaia/ui/scheduler.py(~1,217 lines) — Async timer managersrc/gaia/ui/routers/schedules.py(~238 lines) — REST API endpointssrc/gaia/apps/webui/src/stores/scheduleStore.ts(~120 lines) — Frontend stateHow It Works
MCP Tools (added to Agent UI MCP Server)
schedule_task(name, interval, prompt)— Create recurring tasklist_schedules()— List all tasks with status, next run, last resultcancel_schedule(name)— Cancel a taskpause_schedule(name)/resume_schedule(name)— Pause/resumeget_schedule_results(name, limit)— View past run resultsInterval Parsing
Supports: "every 30m", "every 6h", "every 24h", "daily at 9am", "every monday at 3pm", "hourly", "weekly"
REST API
Database
Proactive Recall
When user starts a new session, agent checks for pending scheduled results and surfaces them: "While you were away, I ran morning_trends and found..."
Dependencies
Files
Acceptance Criteria