Skip to main content

The Problem

Some operations take too long for a request/response cycle:
  • Scraping a website every hour
  • Processing a large file upload
  • Syncing with external APIs periodically
  • Generating weekly reports
Blocking the main thread kills responsiveness. Polling wastes resources.
Task workers handle the heavy lifting. Register a worker, create tasks, and ElizaOS executes them in the background with built-in persistence and scheduling.

Quick Start

1. Define a Task Worker

2. Register the Worker

3. Create Tasks

Task Lifecycle

Task Types

Task Interface

Task Metadata

TaskWorker Interface

Managing Tasks

Query Tasks

Update Tasks

Delete Tasks

Recurring Tasks

Set metadata.updateInterval to create tasks that run periodically:

Error Handling

Handle errors gracefully in your workers:

Best Practices

Keep workers idempotent

Tasks may be retried on failure. Design workers to handle duplicate execution safely.

Use meaningful tags

Tags make querying easier. Use consistent naming like sync:crm, schedule:daily.

Set reasonable intervals

Avoid too-frequent recurring tasks. Consider rate limits and system load.

Validate before creating

Use the validate function to prevent invalid tasks from being queued.

Common Patterns

Triggered by Actions

With Progress Updates

Chained Tasks

Next Steps

Actions Reference

Trigger tasks from agent actions

Events System

Monitor task lifecycle with events

Jobs API

External task creation via REST

Database Adapter

Task persistence internals