Skip to content
Français

Your first workflow

Connect an agent task to a function and inspect their typed result.

After your first task, add a second step that reads its result. This lesson uses the same committed README and configuration; it does not need failing tests or a checkpoint.

Save these three files beside outpost.config.ts. The first declares the agent task, the second builds a summary, and the last starts the workflow.

import { defineIsolatedTask } from "@elie-laloum/outpost/workflows";
import { repository, sandboxProvider, coder } from "./outpost.config.ts";

export const review = defineIsolatedTask({
  key: "review",
  request: () => ({
    repository,
    sandboxProvider,
    agent: coder,
    branch: { mode: "named", name: "outpost/workflow-review" },
    brief: { text: "Summarize the README setup steps without editing files." },
  }),
});
import { defineTask } from "@elie-laloum/outpost/workflows";
import { review } from "./review-task.ts";

export const summary = defineTask({
  key: "summary",
  after: [review],
  perform: (context) => ({
    text: context.value(review).text,
    branch: context.value(review).branch,
    commits: context.value(review).commits.length,
  }),
});
import { defineWorkflow } from "@elie-laloum/outpost/workflows";
import { review } from "./review-task.ts";
import { summary } from "./summary.ts";

const result = await defineWorkflow("readme-review", [review, summary]).start();
result.unwrap();
console.log(result.value(summary));
// Example output: { text: 'Install ...', branch: 'outpost/workflow-review', commits: 0 }

The agent reads the README first. If that task succeeds, your summary function runs and the script prints its result.

node workflow.ts

Inspect the answer, branch name and commit count. unwrap() throws if the workflow did not succeed, so the script does not print a successful summary after a failed task. This example asks for no edits and never integrates the branch.

after: [review] makes summary wait and lets it read context.value(review) with the correct TypeScript type. Neither task starts when declared: .start() runs the graph. The isolated task opens and closes its own sandbox; your summary runs in the Node.js process.

This run keeps its outputs in memory. A checkpointed workflow needs JSON outputs from every stored task, including the agent step: follow Save and resume a workflow when you need that behavior.

Tasks and dependencies covers other task types and results. Use a verification loop when a real test must accept the work, and offline workflow tests to exercise your control flow without model calls.

API: defineIsolatedTask · defineTask · defineWorkflow.