Task

A task defines background work. It is the target that a task run executes.

A task can be reused across callers. A run records one execution.

Characteristics

  • A task has a stable ID.
  • A task defines the function to run.
  • A task can receive input from a caller or run.
  • A task returns a result that the runner can record.

Boundary

Keep reusable behavior in the task definition and execution state in the run.

Use a task when work should run outside a request or chat turn. Tasks are useful for sync runs, imports, cleanup, and other background operations.

Wrong fit

Do not use a task for interactive model reasoning, streamed chat output, or work that must stay inside the current HTTP request. Use an agent or app route for those cases.

For implementation steps, see Tasks.