Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/content/docs/agents/api-reference/schedule-tasks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { Agent } from "agents"
export class SchedulingAgent extends Agent {
async onRequest(request) {
// Handle an incoming request
// Schedule a task 5 minutes from now
// Schedule a task 10 minutes from now
// Calls the "checkFlights" method
let { taskId } = await this.schedule(600, "checkFlights", { flight: "DL264", date: "2025-02-23" });
return Response.json({ taskId });
Expand Down Expand Up @@ -54,11 +54,11 @@ let task = await this.schedule(10, "someTask", { message: "hello" });
// schedule a task to run at a specific date
let task = await this.schedule(new Date("2025-01-01"), "someTask", {});

// schedule a task to run every 10 seconds
// schedule a task to run every 10 minutes
let { id } = await this.schedule("*/10 * * * *", "someTask", { message: "hello" });

// schedule a task to run every 10 seconds, but only on Mondays
let task = await this.schedule("0 0 * * 1", "someTask", { message: "hello" });
// schedule a task to run every 10 minutes, but only on Mondays
let task = await this.schedule("*/10 * * * 1", "someTask", { message: "hello" });

// cancel a scheduled task
this.cancelSchedule(task.id);
Expand Down
Loading