Scheduled tasks API
Schedule recurring prompts for your agents using cron expressions. You can create, update, list, and delete scheduled tasks through these endpoints.Scheduled tasks are processed by an inline scheduler that runs inside the API process. The scheduler polls for pending tasks every 30 seconds and executes up to 10 tasks per cycle. Each task is dispatched as an HTTP request to the target agent with a 30-second timeout.
Each tick claims due tasks atomically using
SELECT ... FOR UPDATE SKIP LOCKED. Tasks are only marked completed when the agent returns a 2xx response. Failed dispatches are re-queued with backoff or marked failed once attempts reaches maxAttempts. See Execution lifecycle below.All scheduled task endpoints require session authentication. Tasks are scoped to the authenticated user — you can only manage tasks for agents you own.
List scheduled tasks
Query parameters
Response
Task object
Errors
Create a scheduled task
Request body
Example request
Response (201 Created)
Returns the created task object.Errors
Update a scheduled task
Request body
Example request
Response
Returns the updated task object.Errors
Delete a scheduled task
Request body
Response
Errors
Execution lifecycle
Each scheduled task moves through a small state machine driven by the inline scheduler. Thestatus field on the task object reflects the current state.
Status values
Atomic claim
Each scheduler tick claims due tasks usingSELECT ... FOR UPDATE SKIP LOCKED inside a single atomic statement. This guarantees that overlapping ticks, concurrent replicas, or restarted workers can never claim the same task twice. Up to 10 tasks are claimed per tick.
Retry behavior
When a dispatch fails — the agent returns a non-2xx status, the request times out, or the network call raises — the task is settled as follows:
- If
attempts < maxAttempts, the task is re-queued.nextRunis set toNOW() + backoff,statusis reset topending, andlastErroris updated. The task is picked up again on a future tick. - If
attempts >= maxAttempts, the task is markedfailedand stops retrying.
The backoff is
min(30 × attempts, 300) seconds. The default maxAttempts is 5.
Stale-claim recovery
If a worker dies mid-dispatch (process crash, container restart, network partition), the task can be left inrunning state with no worker driving it forward. On every tick, the scheduler scans for tasks that have been running for more than 10 minutes and returns them to pending with nextRun = NOW(), lastError = "Recovered after stale worker lock". They are then picked up on the next tick.
You should never see a task stuck in running for more than 10 minutes during normal operation.