A task represents a single conversation thread between your application and an agent or workforce. When you send a message, the SDK returns aDocumentation Index
Fetch the complete documentation index at: https://relevanceai.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Task — everything that happens next flows through it.
The shape of a task
Task status
Every task has astatus field. The SDK simplifies the platform’s internal states into a concise set:
| Status | Meaning |
|---|---|
not-started | Created locally, not yet sent |
idle | Agent is idle, awaiting input |
paused | Execution has been paused |
queued | Waiting to start (capacity, queue) |
running | Agent is actively processing |
action | Requires approval or has escalated |
completed | Finished successfully |
cancelled | Cancelled before completion |
error | Encountered a failure |
How internal platform states map to SDK statuses
How internal platform states map to SDK statuses
The platform uses more granular internal states. The SDK maps them to the statuses above so application code doesn’t need to handle every variation.
For workforce state mappings, see Workforces.
| Platform state | SDK status |
|---|---|
idle | idle |
starting-up | queued |
waiting-for-capacity | queued |
queued-for-approval | queued |
queued-for-rerun | queued |
running | running |
pending-approval | action |
escalated | action |
paused | paused |
completed | completed |
cancelled | cancelled |
timed-out | error |
unrecoverable | error |
errored-pending-approval | error |
Is the task still active?
isRunning returns true when the status is queued or running:
Fetch message history
Retrieve every message on a task withgetMessages:
after date:
isAgent, isTool, and so on) work here.
Listen for events
Tasks emit events in real time as the conversation progresses. There are three event types:| Event | When it fires |
|---|---|
"message" | A new message is received |
"error" | An agent error occurs |
"update" | Task metadata changes (e.g., status) |
The “message” event
The primary event for agent responses, tool executions, and streaming content:The “error” event
Fires when the agent runs into a failure:The “update” event
Fires when the task’s metadata changes, such as a status transition:Subscriptions are automatic
The first call toaddEventListener on a task activates its subscription. There’s no need to call subscribe manually.
Once subscribed, the SDK keeps the task up to date by polling for new messages and metadata changes, and opens a streaming connection when available to deliver real-time thinking and typing events. See Streaming for details.
The SDK manages the polling frequency internally — faster when the task is active, slower when idle. This is transparent to the application.
Clean up
Always callunsubscribe when a task is no longer needed. This stops the polling loop and closes any active connections, freeing network and memory resources.
unsubscribe from the cleanup or teardown handler.

