task node creates a task in Effective, assigns it to users or groups, and by default waits for
one answer that matches a result schema. Use it for approvals and other decisions a person must
make. Use an agent when an agent session should do the work
instead.
Syntax
task id=approve-payout
Fields
The fence takes no attributes after
id, and its body takes no other fields. There is no timeout,
checkpoint or auto-approval field.
Assignees
Each selector isuser:<user-id> or group:<group-id>. IDs contain letters, digits, ., _,
- and @; spaces, a second colon and empty IDs are invalid. Agent sessions can’t be
assignees.
A literal list is checked when you compile. assignees can also be an expression, such as
$inputs.reviewers or a list with a template. The resolved values are checked before the task is
created, and Effective checks that each assignee exists and is allowed when it creates the task.
To assign the task to the person the run acts as, use a template:
$run.principal.type is product-user. A run started by a trigger acts as the
trigger’s run-as identity.
A group stays assigned as a group. It isn’t expanded to its members when the task is created, so
membership changes still apply. A procedure’s task can’t be reassigned by hand: its assignees are
the ones the procedure names. Only a task’s assignees can answer it.
Title and instructions
title and instructions interpolate {{ $name.path }} references. Each must be a required
string, number or boolean; an optional, object, array or null value fails before the task is
created. Interpolation doesn’t recurse, and the rendered Markdown is sanitized. Prose elsewhere in
the document never becomes part of the instructions. The rendered title must still be one line
and not empty.
Prefill
result.prefill fills the form with values the run already has, such as a recommendation from an
earlier agent step. It is a reference to an object or a built object:
default in the result schema still applies; a prefill value wins for the same
property.
Prefill only fills the form. It doesn’t submit anything or count as the person’s answer. The run
continues only when someone submits a complete answer that matches the schema.
Choices from earlier steps
To offer a pick list whose options come from the run, putx-effective-options on a string inside
the result schema:
schema id=product-selection
Built-in options are two-letter codes, shown with their full names. A string field shows a single
select; an array with
uniqueItems: true shows a multi-select.
- The options are read just before the task is created and stored with it. Answers are checked against that exact list.
- A list must have 1 to 1,000 unique, nonempty strings. Each option is at most 1,024 bytes, and all options together at most 65,536 bytes.
x-effective-optionsworks only on atype: stringschema, and not together withenumorconst.- A schema that uses it may be used only as a task’s
result.schema. Using it anywhere else, such as a task input, an agent result, avaluenode or a procedure output, fails withPROC-SCHEMA-004. Use a plainenumthere.
The answer envelope
Inawait mode, the output is an envelope, not the bare answer. Read the answer through
$output.value, for example $payout_approval.value.approved.
The fence’s
attachments are inputs shown to the assignee. The envelope’s attachments and
outputArtifactId are what the person attached when answering. If later steps must use a file,
ask for its ID in the result schema too.
Create without waiting
Withmode: create, the node creates the task and continues as soon as the task exists. Its
output is a task handle, not an answer. The handle’s one member for authors is url, a link to
the task in the run, which you can post to a chat channel or send by email.
A later wait with task: takes the handle and waits for the answer. It doesn’t create a second
task, and its output is the same answer envelope as await mode:
wait id=wait-for-refund
Example
An underwriter approves cancelling a policy for nonpayment and picks the states that must get a notice. The note starts with the billing system’s note. The group ID and policy values are illustrative.nonpayment-cancellation.procedure.md
{ "approved": true, "notice_states": ["OH", "PA"] } ends the run with cancelled: true. A real cancellation would put the write to your policy system in the approved
branch, after the approval.
Post the link, then wait
This version assigns the task to the person who started the run, posts the task’s link, and only then waits.@local.post-to-channel is an effect declared in the same document; its schemas and
code are left out here.
task id=approve-refund
call id=post-link
wait id=wait-for-refund
On retry and resume
- One task per step. Effective creates the task once for the step. A resumed run doesn’t
create it again. Inside a
repeatorfor-each, each round or item gets its own task. - Fixed at creation. The input, attachments, options from
x-effective-optionsand the prefill are resolved once, just before the task is created, and stored with it. Nothing done to the task later recomputes them. - The first valid answer wins. The first answer that matches the schema becomes the step’s
result. A duplicate or late answer can’t move the run forward twice. Through the API, an answer
that doesn’t match is refused with
422 invalid_answer, and a second answer to a finished task with409 task_not_open. See Answer a task. - The record doesn’t change. The task ID, submission ID, answerer and time are recorded and never rewritten.
- Early answers wait. In
createmode, an answer that arrives before the run reaches itswaitis kept and used when the wait is reached.
Common errors
Two prefill cases also fail with
PROC-SCHEMA-005:
- A prefill value for a field with
x-effective-options, because the options aren’t known until the task is created. Prefill other fields instead. - A whole-object prefill, such as
prefill: $recommendation.value.proposed, whose schema doesn’t declare one of the result’s properties (source schema does not declare the target property). Declare that property in the source schema, optional is fine, or build the prefill field by field.
See also
- agent node: the same envelope, produced by an agent session
- wait node: wait for a task created with
mode: create - choice node: route on the answer
- People and agents
- Answer a task from your own system