Tasks
Tasks are units of work that agents execute. They provide structured job management with tracking, retries, dependencies, and deadlines.
For full documentation, see Tasks (Full Guide).
Quick Overview
Why Tasks?
While conversations are great for interactive dialogue, many agent workloads are better modeled as discrete jobs:
- Batch processing: Process 100 documents overnight
- Background work: Generate reports while users sleep
- Scheduled jobs: Daily data sync at 2 AM
- Dependent work: Task B waits for Task A to complete
Task Types
| Type | Description |
|---|---|
| Manual | Created and triggered by users or API calls |
| Scheduled | Run automatically on a schedule |
| Triggered | Execute in response to webhooks |
Basic Example
const task = await client.tasks.create({
name: 'Generate Q4 Report',
type: 'manual',
assignedAgentId: 'agent-123',
input: {
quarter: 'Q4',
year: 2024
}
});
// Run it now
await client.tasks.run(task.id);
Task Lifecycle
pending → in_progress → completed
│
└──→ failed (retry)
Full documentation: Tasks (Complete Guide)