Agent Scheduler • AI Agents Framework
AgentScheduler: Scheduler for running PraisonAI agents periodically.
AgentScheduler
Defined in the Agent Scheduler module.
AI Agents Framework
Scheduler for running PraisonAI agents periodically.
Features:
- Interval-based scheduling (hourly, daily, custom)
- Thread-safe operation
- Automatic retry on failure
- Execution logging and monitoring
- Graceful shutdown
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#8B0000', 'primaryTextColor': '#fff', 'primaryBorderColor': '#710101', 'lineColor': '#189AB4', 'secondaryColor': '#189AB4', 'tertiaryColor': '#fff' }}}%%
graph LR
input["Input Data"] --> agent["Agent: AgentScheduler"]
agent --> output["Output Result"]
style agent fill:#8B0000,color:#fff
style input fill:#8B0000,color:#fff
style output fill:#8B0000,color:#fffConstructor
AnyThe PraisonAI agent or AsyncPraisonAgentExecutor instance to run.
strThe prompt / task string passed to the agent on each run.
Optional[Dict[str, Any]]Optional extra config (reserved; currently unused).
Optional[Callable[[Any], None]]Invoked with the agent’s result after a successful run. Sync or async; exceptions are logged, not raised.
Optional[Callable[[Exception], None]]Invoked with the last captured exception after max_retries attempts fail. Sync or async; exceptions are logged, not raised.
Methods
Start scheduled agent execution.
stop()Stop the scheduler gracefully.
get_stats()Get execution statistics.
execute_once()Execute agent immediately (one-time execution).
Usage
scheduler = AgentScheduler(agent, task="Check news")
scheduler.start(schedule_expr="hourly", max_retries=3)
# Agent runs every hour automatically
scheduler.stop() # Stop when neededSource
View on GitHubpraisonai/agent_scheduler.py at line 119