Skip to content

Scheduled Autonomy: recurring task scheduler for Agent UI #550

@kovtcharov

Description

@kovtcharov

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

  • Agent can create recurring tasks via MCP
  • Scheduler fires tasks on interval using asyncio timers
  • Tasks survive server restart (reloaded from DB)
  • Results stored and surfaced proactively
  • Pause/resume/cancel work correctly
  • Frontend schedule management panel
  • Concurrent tasks don't interfere
  • Graceful shutdown cancels timers cleanly

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentchatChat SDK changesdomain:automationScheduler, autonomy, RAG, web search, watchers, researchelectronElectron app changesenhancementNew feature or requestp0high prioritytrack:consumer-appHermes-competitor consumer product — mobile-first, voice + messaging + memory + skills

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions