Skip to content

The pipeline file

A pipeline is a TypeScript file named for the pipeline, such as pipelines/bug-fix.ts for bug-fix. It lives in a repo on the forge, under pipelines/ on the default branch. It exports one pipeline as its default export. It imports types only, with import type, because the server loads each version from its stored source, outside the repo. The types come from shared/pipeline.ts.

  • description is the sentence shown on the pipeline’s page and in the pickers.
  • agent names the agent whose sessions run the agent stages, unless a stage names another. A run cannot start while the team has no unarchived agent with that name.
  • runsOn is box or home. box claims a box for each run. home uses the agent’s home machine.
  • spendCapUsd is a number above 0. A run stops once its sessions have cost that much. A repo’s policy can lower it.
  • triggers is a list of the ways a run can start.
  • start names the first stage.
  • stages maps each stage name to a stage.
  • { kind: 'manual' } and { kind: 'webhook' } record that people start the pipeline from the app or another system starts it through its webhook. Agents does not read them. Any pipeline with a working version starts from the app and from its webhook.
  • { kind: 'forge', event: 'issues', action: 'opened', label?: string } starts a run from a forge issue. With a label, the issue must carry that label. Without one, the issue must be newly opened.
  • { kind: 'cron', schedule, title, body?, repo } starts a run on a schedule. schedule has five fields, minute, hour, day of month, month and day of week, in the server’s local time. Each field takes *, numbers, lists, ranges and steps. repo is the forge path of the repo, such as team/shop. After downtime, the server starts at most one run per schedule, for the latest time that came due in the last day.

Every stage has next, a map from each outcome the stage can end with to where the run goes. A destination is one of three things.

  • A stage name.
  • { done: 'succeeded' | 'failed', note }, which ends the run with the note.
  • { handoff: reason }, which asks a person, as How a run goes describes.

The server requires next to handle every outcome the stage can end with. The outcomes of a stage depend on its kind.

An agent stage is a turn of an agent’s Claude session in the task’s workspace. Its outcomes are the keys of its next.

  • prompt(ctx) returns the text sent to the agent.
  • agent names another agent for this stage.
  • model sets the Claude model for this stage, such as haiku for cheap reading. The agent’s own model applies when unset.
  • allow lists tools the stage may use without asking a person, in Claude’s --allowedTools form.
  • maxAttempts sets how many tries before a person takes over. It defaults to 3.
  • playbooks runs the stage inside the playbook plugin, as a person’s coding session does.
  • document names a file the agent must leave in the task folder, with the headings it must have, before the stage counts as done. plan: true marks the file as the plan, which is linted and pinned at its gate.

A check stage runs command(ctx) in the repo’s folder on the run’s machine. It ends as passes on exit code 0 and fails otherwise. It times out after 600 seconds. maxAttempts defaults to 3.

An action stage does something the runner does itself. title(ctx) sets a pull request’s title, which is the report’s title by default. text(ctx) sets a pull request’s description or a comment, and is required for open_pull_request, close_issue and ask_reporter. Every action can end as failed.

  • open_pull_request pushes the task branch and opens a pull request. Outcomes are done and failed.
  • merge_pull_request merges that pull request and marks the run’s proposal approved. Outcomes are done and failed.
  • close_issue comments on the report’s issue and closes it. Outcomes are done and failed.
  • ask_reporter comments one question on the report’s issue and leaves it open. Outcomes are done and failed.
  • score_change pushes the task branch and scores the one pipeline file it changed on replays. Outcomes are better, not_better, refused and failed.
  • pick_sessions picks an agent’s unread sessions. Outcomes are picked, none and failed.
  • record_findings keeps the findings whose quotes the runner can find. Outcomes are ready, waiting and failed.
  • propose_hunks turns the reported hunks into a proposal. Outcomes are proposed, refused and failed.
  • replay_sessions replays the turns behind a proposal with and without the change. Outcomes are replayed, unscored and failed.
  • decide_replays scores both versions from the judge’s verdicts. Outcomes are better, not_better and failed.
  • settle_hunks records the decision on every hunk and applies the kept ones. Outcomes are applied, declined and failed.
  • merge_change merges on a repo with a policy. Outcomes are done, stale and failed.
  • deploy asks the deployer to release what the run merged. Outcomes are done, rolled_back and failed.

How coach and improve prove a change explains the learning actions. Run a change through a repo policy explains merge_change and deploy.

A gate stage waits for a person and ends as approved or rejected. question(ctx) returns the text shown. labels names the two buttons with approve and reject when those words would not say what happens. role is one of plan, protected, suite, merge or deploy, and applies only on a repo with a policy.

Five more kinds run only on a repo with a policy. The runner, not an agent, decides how each ends.

  • route has an agent pick a playbook. Its outcomes are the playbooks named in next that the policy allows, from change, bug, docs and dependency.
  • verify runs the static gates and the box’s commands. Outcomes are passes, fails and stopped.
  • review has reviewers on other models judge the change. Outcomes are clean, fix and overruled. It needs reviewers, author, prompt and allow.
  • confirm has a fresh agent check the plan against the change. Outcomes are verified, fix and overruled. It needs verifier, author, prompt and allow.
  • suite runs the policy’s full suite on the change merged into main. Outcomes are passes and fails.

prompt, command, question, title and text each receive a context with these fields.

  • report is the title, body, and where present the issue number, link and author.
  • openIssues is the other open issues on the repo when the run started.
  • results holds the latest result of each finished stage, with its outcome, summary and data.
  • attempts counts how often each stage ran.
  • repo is the workspace’s first repo as a folder name. taskFolder is the task’s folder for documents.
  • comments is the open comments on the task’s documents, oldest first.
  • replay is true when the run replays a past one.
  • playbook is the playbook a route stage picked, with its guide, or null.

The server loads every version before it can become current. A version that fails any of these shows It does not load and the reason on the pipeline’s page, and is never current.

  • The file exports a pipeline whose stages is an object.
  • agent is a non-empty string, runsOn is box or home, spendCapUsd is above 0, and triggers is a list.
  • start names a stage, and every next destination names a stage that exists or is a done or handoff.
  • Every stage has a kind from the list above and the fields its kind requires.
  • Every stage’s next handles every outcome the stage can end with.
  • A route stage’s next names only the four playbooks.
  • A gate’s role is one of the five roles, and a document has a path, headings and a plan flag.