# Tasks (/docs/tasks)

A Task is one piece of work an agent does: a prompt, the coding agent that
works on it, and its transcript. It runs on a Box, the machine CoreSpeed
gives an agent, or on a member's machine through [Tie](/docs/cli/tie). The
`tasks__*` tools let any agent client start Tasks, read them, send them
messages and archive them, on the same `/mcp` seam as everything else, so
identity, organization holds, API-key caps, approvals and activity recording
apply.

The Agents area, where Tasks and [Routines](/docs/routines) live, is a
preview: it may change at any time.

## Tools

| Tool                     | Use it for                                                                      | Who may call it |
| ------------------------ | ------------------------------------------------------------------------------- | --------------- |
| `tasks__list`            | The Tasks you may see, newest first, a page at a time.                          | Everyone        |
| `tasks__peek`            | One Task's state, its Box's health, and a page of its transcript.               | Everyone        |
| `tasks__spawn`           | Start a Task with a prompt, in a space, a repository and an engine.             | Everyone        |
| `tasks__send`            | Send a Task a message; it waits until the Task's current turn ends.             | Everyone        |
| `tasks__archive`         | Archive a Task now, or after a delay.                                           | Everyone        |
| `tasks__group`           | Put a Task and every Task it started in a named group, or in none.              | Everyone        |
| `tasks__schedule_wakeup` | Wake this Task later with a prompt: once, or on a cron.                         | A Task          |
| `tasks__list_wakeups`    | This Task's pending wakeups, soonest first.                                     | A Task          |
| `tasks__cancel_wakeup`   | Cancel one of this Task's wakeups.                                              | A Task          |
| `tasks__show_widget`     | Draw an HTML widget in this Task's own transcript.                              | A Task          |
| `tasks__subscribe`       | Follow a Task: get a notification when it finishes a turn or waits on a person. | A member        |
| `tasks__unsubscribe`     | Stop following a Task.                                                          | A member        |
| `tasks__answer`          | Answer a question a Task you follow is waiting on.                              | A member        |

"Everyone" is a member (with a session or a personal API key), a Task and a
space API key. A tool that is not for the caller is not in its `tools/list`.
The tools are free: a call costs no credits. A Task's Box is billed by its
running time, as [Billing](/docs/billing) describes, and a call that starts
or wakes a Box (`tasks__spawn`, `tasks__send`, `tasks__answer`) is held when
the organization has neither credits nor Box allowance left.

## Who sees a Task

Every Task works in one space. A member sees the Tasks of the spaces they are
in, and the Tasks lent to those spaces. A Task and a space API key see the
Tasks of their own space and of the everyone space, and the Tasks lent to
their space. Archiving a Task needs the level `use` in its space, and
grouping one needs `use` on the first Task of its family; a loan of a Task
never gives either.

## Start a Task

`tasks__spawn` takes the `prompt`, which is the Task's first message and all
it is told. `repository` (as `owner/name`) and `branch` (default `main`) give
it a repository; `engine`, `model` and `effort` pick the coding agent, each
with a default; `device` runs it on a member's machine instead of a Box.
`space_id` names the space it works in; you need the level `use` there.
Without it, the Task works in the caller's own space: a member's personal
space, or a space API key's space.

* **From a space API key.** The key starts a Task only in its own space, and
  the Task names the key as its maker: no person shows as its creator.
* **From a Task.** A Task's child works in the parent's space, with the
  parent's environment and tools, on a new Box of the same kind and size
  (or on the device you name). It does not see the parent's files: pass
  them through the repository or Drive. The parent is told when the child
  finishes. At most 50 Tasks of one family run at once.

The answer holds the new Task's `id` and `agent_id`, and `start_error` when
its Box could not start yet. Peek the Task to follow it.

## Messages and archives

`tasks__send` queues a message for a Task; it is delivered when the Task's
current turn ends. A member's message is theirs. A space API key's message
reaches the Tasks of its space as the key, and a Task's reaches the Tasks it
may see (its parent, its children, its space) as the Task: both are text
only. Pass `submission_id` to make a retry the same message.

`tasks__archive` archives a Task now, which stops its Box, or after
`after_seconds`. A member, a Task or a space API key archives a Task at the
level `use` in its space. A Task never archives itself: it ends its turn
instead.

## A Task's own tools

The wakeup tools and `tasks__show_widget` act on the calling Task's own
session, so only a Task has them. A Task holds at most 20 wakeups;
`delay_seconds` is at least 60, `at` is at most 30 days ahead, and a
repeating wakeup stops after 7 days. A widget's `html` is at most 100,000
characters.

Following a Task and answering its questions are a person's own acts, so only
a member has `tasks__subscribe`, `tasks__unsubscribe` and `tasks__answer`.

## Errors

| Code                                     | Meaning                                                                                                    |
| ---------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| `task_not_found`                         | No Task with that ID that you can see.                                                                     |
| `level_too_low`                          | Archiving or grouping takes `use` in the Task's space; a loan never gives it.                              |
| `space_level_too_low`, `space_not_found` | `tasks__spawn`: you are below `use` in that space, or not in it.                                           |
| `space_key_refused`                      | A space API key asked for what is not its own: a Task in another space, or a person's or a Task's own act. |
| `self_archive`                           | A Task tried to archive itself.                                                                            |
| `task_message_text_only`                 | A message from a Task or a space API key carried more than text.                                           |
| `family_cap`                             | 50 Tasks of this family already run.                                                                       |
| `too_many_wakeups`                       | The Task already has 20 wakeups.                                                                           |
| `task_only`, `html_too_large`            | `tasks__show_widget`: the caller is not a Task, or the widget is too large.                                |
| `plan_limit`, `payment_required`         | The plan does not allow the start, or the organization is out of credits.                                  |
| `unavailable`                            | The service could not be reached; retry in a minute.                                                       |

## Elsewhere

[`cs tasks`](/docs/cli/tasks) drives the same Tasks from a terminal, and
[Routines](/docs/routines) start them on a schedule or an event.

A member turns `tasks` off for their own personal space in Dashboard → Tools,
and a team space has its own switch; CoreSpeed can turn it off for a whole
organization. Off, it hides the `tasks__*` tools from `tools/list` in that space; see
[Capability controls](/docs/capability-controls).