Scheduler

Let an agent create and manage AgentOS schedules.

SchedulerTools gives an agent natural-language control over the AgentOS Scheduler. It wraps ScheduleManager so an agent can create, list, trigger, enable, disable, delete, and inspect recurring schedules.

Prerequisites

Install the scheduler extras and the openai library:

uv pip install "agno[scheduler]" sqlalchemy "psycopg[binary]" openai

Schedules are stored in the same database used by AgentOS. To execute schedules, run AgentOS with scheduler=True.

The Agent model uses an OpenAI key, separately from any toolkit provider credentials.

Set OpenAI Key

Set your OPENAI_API_KEY as an environment variable. You can get one from OpenAI.

export OPENAI_API_KEY=sk-***

This fragment configures the toolkit; it does not start a server or execute a schedule. Set up the database and serve this agent using the scheduler guide.

Configuration Example

cookbook/05_agent_os/12_scheduler/04_scheduler_tools_agent.py
from agno.agent import Agent
from agno.db.postgres import PostgresDb
from agno.models.openai import OpenAIChat
from agno.tools.scheduler import SchedulerTools

db = PostgresDb(
    id="scheduler-tools-demo-db",
    db_url="postgresql+psycopg://ai:ai@localhost:5532/ai",
)

scheduler_agent = Agent(
    id="scheduler-agent",
    name="Scheduler Agent",
    model=OpenAIChat(id="gpt-4o-mini"),
    tools=[
        SchedulerTools(
            db=db,
            default_endpoint="/agents/scheduler-agent/runs",
            default_timezone="UTC",
        )
    ],
    instructions=[
        "When the user asks for recurring work, create a schedule.",
        "Confirm the cron expression and timezone.",
    ],
    db=db,
    markdown=True,
)

When targeting an AgentOS /runs endpoint, the schedule payload must include a message field.

Toolkit Params

ParameterTypeDefaultDescription
dbAny-Database adapter implementing scheduler methods.
default_endpointOptional[str]NoneEndpoint to call when a schedule fires.
default_methodstr"POST"HTTP method for scheduled requests.
default_timezonestr"UTC"Timezone used for cron expressions.
default_payloadOptional[dict]NoneDefault request payload.
user_idOptional[str]NoneFixed schedule owner; otherwise uses RunContext.user_id. Without either value, operations are unfiltered by user.
include_agentsOptional[Sequence[Agent]]NoneLive code-defined agents served by this process, used for target validation.
include_teamsOptional[Sequence[Team]]NoneLive code-defined teams used for target validation.
include_workflowsOptional[Sequence[Workflow]]NoneLive code-defined workflows used for target validation.

Toolkit Functions

FunctionDescription
create_scheduleCreate or update a recurring schedule from a cron expression.
list_schedulesList schedules.
get_scheduleFetch one schedule by ID.
delete_schedulePermanently remove a schedule.
enable_scheduleEnable a paused schedule.
disable_schedulePause a schedule.
trigger_scheduleMake a schedule due immediately; the poller performs execution.
get_schedule_runsRead schedule execution history.

All functions have sync and async variants.

Developer Resources