Connect tasks and dependencies
Define tasks, declare what they depend on and read their typed results.
The first example runs entirely in Node.js: install Outpost in an ESM project, save it as dependencies.ts and run node dependencies.ts. No agent, account or sandbox is needed to learn the graph.
Define tasks and a workflow
Section titled “Define tasks and a workflow”Declare each step with a task constructor, then give the tasks to defineWorkflow(). Dependencies determine execution order and which earlier results a task may read.
Declare named inputs when the task consumes dependency results. Outpost adds those tasks to after and supplies their typed values to perform. Keep after for ordering-only dependencies; duplicate tasks are added once. The dependency mapping is copied when the task is defined.
It prints { reviewed: 1 }. defineTask() and defineWorkflow() only declare the graph: nothing runs until start().
Read a dependency
Section titled “Read a dependency”List a task in after, then read its output with context.value(task). The value keeps the type returned by that task’s perform.
context.value() throws for a task missing from after, even if it already ran. A task starts only once every task in its after list is done.
Fix graph errors
Section titled “Fix graph errors”defineWorkflow() checks the graph before anything runs and throws on the first error.
| Mistake | Error |
|---|---|
| Two tasks share a key | Duplicate task: test |
A task in after is not in the workflow’s list | publish: missing dependency lint |
| Tasks depend on each other in a loop | Dependency cycle at report |
A key does not match [A-Za-z0-9][A-Za-z0-9._-]* | Invalid task key: …, from defineTask() |
Read the results
Section titled “Read the results”start() resolves with a WorkflowResult once no task can run any more, even when tasks failed. It rejects when an option is invalid or a checkpoint cannot be saved.
It prints failed, then lint failed 2 lint errors and test cancelled: by default, the first failure cancels the tasks that have not finished.
API reference: WorkflowResult and TaskRecord.
Run tasks in parallel
Section titled “Run tasks in parallel”Independent tasks can run together when you increase concurrency. Start with the parallelism and retries guide for a working example. Tasks that share a sandbox must remain sequential; connect them with after.
Skip a task
Section titled “Skip a task”Use condition when a task only makes sense for some inputs. A false condition skips the task and its dependents, and produces no value. See the conditional task example before reading such a result.
Display the dependencies
Section titled “Display the dependencies”diagram() returns the graph as a Mermaid flowchart, for a README or a pull request.
To run tasks against the same files, follow Share a sandbox.
Choose the task type
Section titled “Choose the task type”Start with the declaration that matches who owns the work.
| Your step needs | Use |
|---|---|
| Your own function | defineTask |
| An agent with its own sandbox | defineIsolatedTask |
| An agent or command in an open sandbox | defineAgentTask or defineCommandTask |
| Another attempt after a failed check | A verification loop |
Add approvals, human questions, queued work or artifacts when those steps become necessary.
Limits
Section titled “Limits”- Outputs live in memory for one
start(). A restarted run reruns every task unless you pass a checkpoint. - Approval and pause tasks, interactive tasks, quota pauses,
answersanddecisionsrequire a checkpoint:start()throws without one. - A workflow does not commit, merge or push across tasks as one transaction. To change several repositories, see Multiple repositories.
API: defineTask · defineWorkflow · TaskContext · WorkflowResult · TaskRecord · WorkflowFailure

