Skip to content

Workflows

A workflow is a file under a project's workflows/ directory, next to agents/, sources/, exposures/ and triggers/. Its edges: wire sources, prompts, agents and exposures into a graph. Order, branching and loops live only here. Run a workflow with abt dispatch -s <workflow>.

subagents: in an agent's frontmatter is a different mechanism. It lets that agent call another agent as a tool, from inside its own turn, and it has no effect on the order of workflow nodes. See Subagents.

Each example lists the files it needs, so you can paste it into a project and run abt compile. Compile checks that every file and node a workflow names exists. It does not check fields inside a node, such as a misspelled field: in a conditions: entry.

Run B after A

Save this as agents/a.md, agents/b.md and agents/c.md. It is a plain agent: it declares no order, trigger or input and output fields.

---
description: Replies in one sentence.
---
Reply in one short sentence.

List the agents in order under steps:. Each agent sees the output of the one before it:

# workflows/a_then_b.yaml
steps: [a, b]

steps: is shorthand for edges:, a list of [from, to] pairs. This is the same workflow written as edges::

edges:
  - [START, a]
  - [a, b]
  - [b, END]

START and END are reserved node names. Every path begins at START and must reach END, or compile fails (node(s) with no path to END). A node with several outgoing edges is a fan-out: its targets run in parallel. A node with several incoming edges is a fan-in: it waits for all its predecessors (the nodes with an edge into it), then sees each one's output. Here a and b run in parallel and c runs after both:

# workflows/a_b_then_c.yaml
edges:
  - [START, a]
  - [START, b]
  - [a, c]
  - [b, c]
  - [c, END]

abt graph a_b_then_c prints the flow without calling a model:

a → ↓ c
b → ↓ c

c → END

Straight runs share a line, branches fan out with ├─/└─, and a node with several parents is drawn once in its own block (↓ c points to it).

Sources, prompts and exposures are workflow nodes too, never agent frontmatter. They are covered below.

Schema

A fixed set of keys, extra: forbid — nothing else is legal:

# workflows/<name>.yaml
name: <string>                     # optional — defaults to the file name without .yaml
description: <string>              # optional
trigger: <triggers/*.yaml ref>      # optional — bare name, no vars binding
# or, to bind per-event vars at the ref site:
# trigger:
#   <triggers/*.yaml ref>:
#     vars:
#       <name>: "{{ event.* }}"
max_iterations: <int>               # optional — required if the graph has a cycle,
                                     # an error if it doesn't
token_budget_scope: thread          # optional — run | thread; see below
tags: [finance, tier-1]              # optional — merges into every node's own tags by default;
                                     # also selects the workflow for `abt watch --tags`
steps: [a, b, c]                    # exactly one of steps:/edges:
# or
edges: [...]

trigger: arms the workflow for abt watch. The trigger files and the vars: binding are in Triggers.

Workflow-level tags:

A workflow's tags: merge into every node's own tags: for that dispatch run — a way to label an entire workflow (e.g. finance, tier-1) without repeating the tags on each agent.

Project-wide default (abt.yaml):

config:
  workflows:
    defaults:
      tags_inherit: true   # true | false
Variable Type Effect
ABT_WORKFLOW_TAGS_INHERIT bool Whether workflow tags merge into node tags; overrides abt.yaml when set

Precedence: ABT_WORKFLOW_TAGS_INHERIT (env) → config.workflows.defaults.tags_inherit (abt.yaml) → true (framework default).

Braintrust-specific asymmetry: when tags_inherit is disabled, the workflow's tags are not dropped — they instead apply only to the Braintrust root span for that dispatch run. They do not reach LangSmith or any other observability backend in that case. This is the one backend-specific behavior in an otherwise backend-agnostic feature, so consider it before flipping the toggle off in a project that relies on tags in a non-Braintrust backend.

Workflow-level token_budget_scope:

Every message on a checkpointed thread is a new turn, and by default each turn gets a fresh token_budget. Set token_budget_scope: thread to make this workflow's agents spend one budget across the whole conversation instead (run is the default).

It only fills the scope of agents that declare a token_budget, and an agent's own scope: still wins. Order, highest first: the agent's frontmatter scope: → the workflow → abt.yaml → ABT_TOKEN_BUDGET_SCOPE → run.

One file per workflow, any filename, any depth

Any filename under workflows/. The workflow's name defaults to the filename stem (workflows/a_then_b.yaml → a_then_b); add a top-level name: key to override it. Scanned recursively — subdirectory depth never affects identity, so workflows/team-a/a_then_b.yaml and workflows/a_then_b.yaml name the same workflow, and two files resolving to one name collide (Duplicate workflow name 'a_then_b': workflows/team-a/a_then_b.yaml and workflows/a_then_b.yaml).

# workflows/nightly/digest.yaml — name: overrides the filename stem
name: nightly_digest
steps: [a]

Override the directory in abt.yaml:

paths:
  workflows: workflows   # default: workflows

Node names and edge vocabulary

Each name in edges: must equal the node's name:. For agents and prompts the file name is the default; for sources and exposures name: is required in the file:

Node Name comes from
Agent name: in the agent's frontmatter, else the file stem
Source name: in sources/*.yaml (required)
Prompt name: in the prompt's frontmatter, else the file stem (its directory is ignored)
Exposure name: in exposures/*.yaml (required)

A name that matches no node fails compile: edge references unknown agent 'other_file'.

Terms used in conditional edges:

  • output.<field> — a field of the predecessor agent's output_schema result.
  • when: "{{ output.<field> }}" — the only supported when: form: one field lookup.
  • cases: — maps each value of that field to a target: a node name, or {respond: "text"} to end the path with fixed text and run no agent.
  • default: — required on every conditional edge.
  • event.* — only in a trigger's vars: bindings, where it reads the event that started the run. See Triggers — event fields.

Source nodes

A sources/*.yaml name can appear as a workflow node endpoint, exactly like an agent id — wire it into edges: ahead of the agent that needs its payload. This source reads the last day of a Slack channel:

# sources/standup_notes.yaml
name: standup_notes
type: slack_channel_digest
credentials: slack
config:
  channel_id: C0EXAMPLE01
  lookback_hours: 24

Save this as agents/daily-digest.md:

---
description: Writes the daily standup digest
---
Write a short, upbeat digest of the notes you are given.
# workflows/daily_digest.yaml
edges:
  - [START, standup_notes]     # source_node -> agent_node
  - [standup_notes, daily-digest]
  - [daily-digest, END]

abt compile and abt graph daily_digest run without Slack credentials. abt dispatch -s daily_digest fetches the channel, so it needs a slack entry in profiles.yaml.

A prompts/*.md node between the source and the agent reads it with {{ upstream('name') }} (compile rejects upstream() inside an agent body). See Sources — workflow nodes for the full worked example and the source file's schema.

Prompt nodes

A prompts/*.md file can also appear as a workflow node endpoint, ahead of the agent it composes the task for. Save this as prompts/digest_task.md, then wire it between the source and the agent from the previous section:

Summarize yesterday's standup notes into a short, upbeat digest:

{{ upstream('standup_notes') }}
# workflows/daily_digest.yaml
edges:
  - [START, standup_notes]        # source node
  - [standup_notes, digest_task]  # prompt node reads standup_notes via upstream()
  - [digest_task, daily-digest]   # digest_task's rendered text becomes daily-digest's task
  - [daily-digest, END]

prompts/digest_task.md renders like any other prompt template — {{ var(...) }}, {{ upstream('standup_notes') }} — and its output becomes the downstream agent's actual task text directly (not a <upstream_agent> context block the way a source or agent predecessor's output does). A prompt is only ever a workflow node; the only other way an agent's turn gets a user message is an explicit -p on abt run/abt dispatch.

A prompt's node name is its file's stem — its directory under prompts/ is irrelevant, same as agents/ — so nesting prompts/jira/resolve.md for organization still yields node resolve, and existing workflow references don't break. Give it an explicit name: in a leading frontmatter block only if you want the node name to differ from the filename:

Save this as prompts/jira/resolve.md:

---
name: jira_resolve
---
Investigate and resolve the following Jira ticket.

Exposure sink nodes

A exposures/*.yaml name can also appear as a workflow node endpoint, wired directly after the agent whose result it delivers — there is no exposures: frontmatter field on agents. Save this exposure, then wire it after daily-digest in the same workflow:

# exposures/slack_digest_post.yaml
name: slack_digest_post
type: slack
credentials: slack
config:
  channel_id: C0EXAMPLE02
# workflows/daily_digest.yaml
edges:
  - [START, standup_notes]
  - [standup_notes, digest_task]
  - [digest_task, daily-digest]
  - [daily-digest, slack_digest_post]  # exposure sink node — dispatches daily-digest's result
  - [slack_digest_post, END]

An exposure node is a sink: it may route into another exposure (chaining multiple deliveries off the same result — [first_exposure, second_exposure], [second_exposure, END]) or END, but never back into an agent — compile fails with exposure node 'x' routes into 'y', which is not another exposure or END, since an exposure dispatches a side effect and cannot feed an agent's turn. Each run delivers one predecessor's result to an exposure. If two predecessors both finish for the same invocation, the run fails with E_WORKFLOW_EXPOSURE_FAN_IN. Mutually exclusive branches (for example a when: route) may share one exposure sink.

An exposure node fires when its predecessor completes, not once per dispatch, so its position in the graph decides what it sends. See Exposures — exposure timing. For the exposure file's schema, see Exposures — workflow nodes.

Branching on a structured field: output_schema + when:/cases:

The agent emits a plain structured field via output_schema:; the workflow branches on it. The enum contract, saved as contracts/routing.py:

from typing import Literal
from pydantic import BaseModel, Field

class TriageRoute(BaseModel):
    """``triage``'s classification — read by ``support_ticket``'s conditional edge."""

    route: Literal["refund", "escalate"] = Field(
        description="'refund' for billing/refund asks, 'escalate' for anything needing on-call."
    )
    summary: str = Field(
        description="The ticket in one sentence, keeping every amount, order number and error it mentions."
    )

Save this as agents/triage.md:

---
name: triage
description: Classifies the ticket as refund- or incident-shaped
output_schema: routing.TriageRoute
---

Read the ticket and decide: refund-shaped or incident-shaped?

refund, escalate and close-ticket are plain agents. Save the plain agent from Run B after A as agents/refund.md, agents/escalate.md and agents/close-ticket.md.

The workflow, saved as workflows/support_ticket.yaml. A full workflow can also wire a source, prompt nodes and exposures — see Exposures — exposure timing:

description: Triage an inbound ticket, resolve it, close it out
edges:
  - [START, triage]
  - from: triage
    when: "{{ output.route }}"
    cases: { refund: refund, escalate: escalate }
    default: escalate
  - [refund, close-ticket]
  - [escalate, close-ticket]
  - [close-ticket, END]

triage runs once, normally. The workflow reads output.route from its output_schema-validated result and picks exactly one case. default: is required on every conditional edge — "no matching case" is structurally impossible. close-ticket has two incoming edges, but only one branch runs, so it runs once and sees the output of that branch.

A case target can also be a terminal literal response instead of another agent — cases: { spam: { respond: "ignored" } } — which ends that path with the literal text, no agent runs.

Branching on operators: conditions:

A conditional edge can compare fields of the predecessor's output_schema result directly, with no agent file for the if. Add a numeric field to TriageRoute in contracts/routing.py:

class TriageRoute(BaseModel):
    ...
    amount: float = Field(description="Amount in EUR the customer asks to get back, 0 if none.")

Then save this as workflows/refund_limit.yaml. Refunds above 100 EUR go to escalate:

edges:
  - [START, triage]
  - from: triage
    conditions:
      - { field: amount, op: gt, value: 100, to: escalate }
    default: refund
  - [refund, END]
  - [escalate, END]

Operators: eq, ne, gt, gte, lt, lte, in, not_in. The first matching condition wins, in declared order, and default: is required.

Tool delegation: subagents:

Delegation is declared in the calling agent's frontmatter. Save this as agents/refund-handler.md; its subagents: entry lets the model call refund-policy as a tool:

---
name: refund-handler
description: Resolves a refund request
subagents: [refund-policy]
---

Resolve the refund, consulting refund-policy for eligibility rules.

Save this as agents/refund-policy.md, the agent it may call:

---
description: Answers refund eligibility questions
---

State the refund eligibility rules in two sentences.

Cycles

A retry loop until done. plan, left and right are plain agents: save the plain agent from Run B after A under each of those names. join reports whether the work is done, through this contract, saved as contracts/loop.py:

from pydantic import BaseModel


class JoinResult(BaseModel):
    done: bool

Save this as agents/join.md:

---
description: Merges left and right, and says whether the plan is done
output_schema: loop.JoinResult
---
Merge both answers. Set done to true once the plan is complete.

Save the workflow as workflows/ops/diamond_cycle.yaml. The file sits one directory deep on purpose: workflow identity comes from the filename stem, never from directory depth:

max_iterations: 3
edges:
  - [START, plan]
  - [plan, left]
  - [plan, right]
  - [left, join]
  - [right, join]
  - from: join
    conditions: [{ field: done, op: eq, value: false, to: plan }]
    default: END

abt graph diamond_cycle renders the detected cycle (excerpt):

join
├─ [if done eq False] ↺ plan
└─ [default] END

↺ marks the edge that loops back.

max_iterations caps each node at 3 executions — the attempt that would exceed it raises E_WORKFLOW_MAX_ITERATIONS. It's required on a cyclic graph (Workflow 'x' contains a cycle but declares no 'max_iterations' budget) and an error on an acyclic one (Workflow 'x' declares 'max_iterations' but its graph is acyclic (unused budget)).

Running one node: abt run -s <agent>

abt run -s <agent> runs that agent plus every agent its subagents: can reach (see Subagents). It never runs the other nodes of a workflow.

abt run -s triage -p "Refund my last order"

To run the full workflow instead of one node, use abt dispatch:

abt dispatch -s support_ticket -p "Refund my last order"

Selectors

A selector is a bare agent name:

abt run -s triage
abt test -s triage

A bare name wires the agent's full declared subagents: tree.

abt dispatch vs abt run

Command Runs Example
abt dispatch -s <workflow> A workflow from workflows/ — sources, topology, exposures on success abt dispatch -s support_ticket -p "..."
abt run -s <agent> One agent and the agents it may call through subagents: — no workflow, sources or exposures abt run -s triage -p "..."
abt watch consume Dispatches each queued job, with exposures delivered (no skip flags) abt watch consume --acks-late

See also

  • Agents — frontmatter reference, subagents:, output_schema
  • Subagents — tool delegation
  • Triggers — start a workflow from an event
  • CLI reference — abt dispatch and abt run; abt graph prints a workflow's flow without calling a model
  • Preflight checks — abt debug checks your environment, profile and model connection before a first run