Scheduling
Built-in cron for triggering recurring tasks.
AgentOS comes with a built-in cron-style scheduler. Use it to run morning briefings, daily triage, weekly digests, hourly health checks. Advanced agentic systems like Scout also use it to set reminders and manage their own schedule.
Registered schedules live in the AgentOS database (agno_schedules table) and use the same FastAPI process used by the agents.
1from kern.os import AgentOS23agent_os = AgentOS(4 agents=[agent],5 db=db,6 scheduler=True,7 scheduler_poll_interval=15, # check for due jobs every N seconds8)The scheduler polls agno_schedules every scheduler_poll_interval seconds, fires due jobs, retries failures, and persists state.
Two ways to create schedules
| Pattern | How |
|---|---|
| Agent Managed | Agent has tools to create, read, update active schedules. Users ask the agent to schedule things in chat, agent uses tool calls to manage schedules. |
| Manually Registered | Schedules created in code, registered at startup. |
Agent Managed
Give an agent SchedulerTools and it can schedule its own work via chat:
1from kern.tools.scheduler import SchedulerTools23agent = Agent(4 model="openai:gpt-5.4",5 tools=[6 SchedulerTools(7 db=db,8 default_endpoint="/agents/my-agent/runs",9 default_method="POST",10 default_timezone="UTC",11 ),12 ],13)1415# In Slack: "@MyAgent post a daily digest of open PRs at 9am ET"16# The agent calls SchedulerTools.create_schedule() with a cron expr.The Demo OS contains a Scheduler agent that does this.
Manually Registered
For schedules that should always exist (the daily digest, the hourly sync, the nightly cleanup), create them in your app's lifespan via ScheduleManager:
1from contextlib import asynccontextmanager2from kern.scheduler import ScheduleManager34@asynccontextmanager5async def lifespan(app):6 manager = ScheduleManager(db=db)7 manager.create(8 name="daily_digest",9 cron="0 9 * * 1-5", # weekdays 9am10 endpoint="/workflows/daily-digest/runs",11 if_exists="update", # idempotent on restart12 )13 yield1415agent_os = AgentOS(..., db=db, scheduler=True, lifespan=lifespan)if_exists="update" makes the call idempotent — re-running on restart updates the existing schedule rather than raising or duplicating. Pass "skip" if you want to leave manually-edited schedules alone, or "raise" (the default) to surface accidental name collisions. This is the pattern Coda uses for daily digest, issue triage, and repo sync.
Workflows for multi-step jobs
Schedules fire single endpoints. When the work is multi-step — research, then outline, then draft, then review — you reach for a workflow. Workflows aren't strictly a scheduling feature, but they're the most common thing a schedule fires.
A workflow is a typed pipeline. Steps run in order. Parallel runs them concurrently. Loop repeats until a condition holds. Router picks one branch.
1from kern.workflow import Workflow, Step, Parallel, Loop, Router, Condition23workflow = Workflow(4 name="content_pipeline",5 steps=[6 Step(name="research", agent=researcher),7 Step(name="outline", agent=outliner),8 Loop(9 name="draft_review",10 steps=[11 Step(name="draft", agent=writer),12 Step(name="review", agent=editor),13 ],14 end_condition='last_step_content.contains("APPROVED")',15 max_iterations=3,16 ),17 ],18)Loop.end_condition accepts a CEL expression string (as above) or a callable that takes the iteration's step outputs and returns a bool. Condition is a separate primitive for if/else branching inside a workflow — pair it with Router for dynamic branches, not with Loop.
Workflows are first-class AgentOS citizens: /workflows/<id>/runs POST endpoint, schedulable, traced, persisted in the same db.
| Pattern | Use when |
|---|---|
| Sequential | Steps depend on each other |
| Parallel | Steps are independent and you want fanout |
| Loop with condition | Quality threshold or max iterations |
| Router + Condition | Dynamic branching on input |
| Cross-modal chaining | Output of one agent is input to a different modality (text → speech, code → narration) |
For worked examples, see Demo OS.
Schedule runs and observability
When a schedule fires, AgentOS:
- Looks up the schedule in
agno_schedulesand claims it via a row-level lease. - Calls the configured endpoint (
POST /agents/<id>/runsorPOST /workflows/<id>/runs) over HTTP viahttpx.AsyncClient— the same path an external caller would take, including auth headers. - Records the result in
agno_schedule_runs(status, attempt, timings, error if any) and the underlying run inagno_sessionsandagno_traceslike any other run.
That means scheduled work shows up in the same UI, the same SQL queries, and the same trace tree as ad-hoc work. To see what fired in the last 24 hours:
1SELECT2 s.name,3 sr.status,4 sr.triggered_at,5 (sr.completed_at - sr.triggered_at) AS duration_s6FROM agno_schedule_runs sr7JOIN agno_schedules s ON s.id = sr.schedule_id8WHERE sr.created_at > extract(epoch from NOW() - INTERVAL '24 hours')::bigint9ORDER BY sr.created_at DESC;Timestamps on schedule runs are stored as epoch seconds (BigInt). For the trace of a specific scheduled run, follow the run_id from agno_schedule_runs back to agno_traces. See Observability for the full data model.
Scheduler in HA
Every replica can run the scheduler loop safely. Due schedules are claimed via a row-level lease (locked_by, locked_at on agno_schedules) — the first replica to claim a due job runs it, the others skip. No leader election needed; the lease is the coordination primitive.
If you'd rather keep scheduler polling off your hot request path, pin it to a dedicated replica via deployment config. See Scheduler for tuning details.