# Human in the loop

> A task is a contract between Sommatic AI and a person. The system provides context and evidence; the person provides a structured output that the task validates before it can be completed.

Source: https://docs.sommatic.ai/en/human-in-the-loop/ (updated 2026-11-26)

Sommatic AI does not try to automate everything. It automates what is safe and brings a person in when a case carries
risk or ambiguity. That intervention is a **task**: not a ticket, not a message and not a notification, but a formal
obligation with an assignee, a deadline, the evidence the person needs and the exact output the person must return.

Diagram: A task is a contract: human.task.create opens it, a person claims it, fills the required output and completes it, one named transition at a time.

## What a task holds

| Field                           | What it is                                                                                                    |
| ------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| `title`, `details`              | The goal, and actionable instructions for the person.                                                         |
| `type`                          | `approval`, `data_completion`, `review`, `resolution` or `delegation`.                                        |
| `priority`                      | `low`, `medium`, `high` or `critical`. Orders the inbox.                                                      |
| `assignee`                      | A user or a group: `assignee_type` (`user` or `group`) and the matching `user` or `group` reference.          |
| `ownership`                     | Who claimed it and when: `is_claimed`, `claimed_by`, `claimed_at`.                                            |
| `sla`                           | `due_at` (Unix milliseconds, as a string), `sla_ms` and `is_overdue`, recomputed every time the task is read. |
| `payload`                       | The evidence: `summary`, `evidence` blocks and `linked_entities` (soft references to other records).          |
| `required_output`               | A JSON-schema-like `schema` of what the person must provide, plus an optional `ui_hint`.                      |
| `outputs`                       | What the person provided. It can be prefilled by an upstream node for the person to verify.                   |
| `execution`                     | An optional [app](https://docs.sommatic.ai/en/apps.md) that collects the output instead of the default form.  |
| `organization_id`, `project_id` | Scope of the task.                                                                                            |

Two more types exist for system use: `diagnostic` (a failure that may be a bug) and `telemetry` (a signal for
reporting). They make those tasks easy to filter.

### The required output is the contract

```json
{
  "required_output": {
    "schema": {
      "type": "object",
      "required": ["decision", "reason"],
      "properties": {
        "decision": { "type": "string", "enum": ["approved", "rejected"] },
        "reason": { "type": "string" },
        "notes": { "type": "string" }
      }
    },
    "ui_hint": { "layout": "approval", "require_reason": true }
  }
}
```

The portal renders a form from this schema. A task cannot be completed while a field listed in `required` is missing or
empty.

![A quality inspector at a fruit warehouse loading dock reviews a case on her phone](https://docs.sommatic.ai/images/docs/human-in-the-loop.webp)

## Create tasks from a workflow

The [`human.task.create`](https://docs.sommatic.ai/en/nodes/human.task.create.md) node opens a task in the middle of a run. Its configuration
takes `title` and `description` (both accept [expressions](https://docs.sommatic.ai/en/expressions.md)), `type`, `priority`, the project, the
assignee (a user picked in the studio or an identity from an expression), the due date (a date or an expression such
as `{{ $now.plus({ days: 3 }).toISO() }}`), `sla_ms`, `required_output`, prefilled `outputs` and the `payload`.

| Port      | When                                                                                   |
| --------- | -------------------------------------------------------------------------------------- |
| `created` | The task exists. The output carries `task_id`, `task_title`, `task_type` and `status`. |
| `error`   | A required field is missing or the task could not be created.                          |

A task created with a user assignee starts `claimed` by that user. Without an assignee it starts `queued` and is scoped
by its project.

> **Warning: The run does not wait for the person**
>
> Today `human.task.create` leaves through `created` as soon as the task exists, and the run goes on. The
> `human.approval.gate` node is partial: it configures the approval on the task and returns `accepted` at once, without
> waiting for the decision. Do not place steps that depend on the person's answer after these nodes in the same run:
> the answer lives in the task's `outputs` once the person completes it.

## Work the task

In the portal, **Tasks** shows the inbox of the signed-in person. Opening a task shows its details, its evidence and
the output form (or an **Open App** button when the task is bound to an app). The person claims it, works it and
completes or rejects it; every step is a [transition](https://docs.sommatic.ai/en/human-in-the-loop/task-lifecycle.md).

Through the API, tasks live under `/work-management/task/` (see the
[API reference](https://docs.sommatic.ai/en/api/reference/human-in-the-loop.md)).

## Next steps

- [Task lifecycle](https://docs.sommatic.ai/en/human-in-the-loop/task-lifecycle.md): Statuses, transitions and output validation.
- [Notifications](https://docs.sommatic.ai/en/human-in-the-loop/notifications.md): Tell people about their tasks in real time.
- [Apps and workflows](https://docs.sommatic.ai/en/apps/workflow-bridge.md): Collect a task's output with an app.
