Jobs
Schedule agent tasks
Agents can run on a schedule – daily reports, hourly checks, or one-time tasks.
Quick Start
- Simple Usage
typescript import { Agent, Job } from 'praisonai'; const agent = new Agent({ instructions: 'Generate daily sales reports' }); const job = new Job({ agent, task: 'Create the daily sales summary', schedule: '0 9 * * *' // Every day at 9 AM }); await job.start(); - With Configuration
typescript const job = new Job({ agent, task: 'Check system status', interval: '30m' // Every 30 minutes });
User Interaction Flow
Configuration Levels
// Level 1: String - Cron schedule
const job = new Job({
agent,
task: 'Daily report',
schedule: '0 9 * * *'
});
// Level 2: Dict - With options
const job = new Job({
agent,
task: 'Check status',
interval: '1h',
runOnStart: true
});
// Level 3: Instance - Full control
const job = new Job({
agent,
task: 'Generate report',
schedule: '0 9 * * 1-5', // Weekdays only
timezone: 'America/New_York',
onComplete: (result) => sendEmail(result),
retries: 2
});Schedule Types
| Type | Example |
|---|---|
| Cron | '0 9 *' (daily at 9 AM) |
| Interval | '30m', '1h', '1d' |
| One-time | new Date('2024-03-15') |
API Reference
SessionConfigSession configuration
Best Practices
Use cron for fixed times
Cron is best for “every day at 9 AM” type schedules.
Handle failures
Set retries and notifications for important jobs.
Consider timezones
Always specify timezone for user-facing schedules.