Open History to see the last commit
1# Workflows
2
3A workflow is a TypeScript script that chains agents, plain code, schedules, webhooks, issue and pull request events, and questions to you into one durable run that survives server restarts. Each step's result is saved when it succeeds, so restarts pick up where the run left off and failures do not lose earlier work. Workflows are an early feature: start runs from the `t3` CLI or a trigger, and follow them in the app.
4
5For one prompt on a timer or webhook, use a scheduled task. Use a workflow when work has stages — such as triage, a fix, your approval, and a release.
6
7## Turn on workflows
8
9Workflows are a Labs feature, off by default. Turn on **Settings → Labs → Workflows** for the server that runs them. On a server without a desktop, set `"workflowsEnabled": true` in `userdata/settings.json` in its T3 home (`~/.t3` by default). While off, nothing in the workflows folder runs and `t3 workflow` says how to turn it on; runs are kept and continue once it is on again.
10
11## Create a workflow
12
13Workflow files live in `~/.t3/workflows/` (or wherever `T3CODE_WORKFLOWS` points — a folder or a single file). The server watches the folder and reloads changes without a restart.
14
15- **Ask an agent (recommended):** copy the [`t3-workflows` skill](https://github.com/pingdotgg/t3code/blob/main/skills/t3-workflows/SKILL.md) into your agent's skills folder (such as `~/.claude/skills/` or `~/.agents/skills/`) and describe what you want.
16- **Edit directly:** edit files in `~/.t3/workflows/`, or use **Definitions** on the Workflows page (saving and deleting in the app require terminal access). Before anything has run, open the page with **Open workflows** in the command palette.
17
18A small workflow, saved as `~/.t3/workflows/release.ts`:
19
20```ts
21const { workflow, step, ask, stop, title } = T3;
22
23export default workflow(
24 "release",
25 { version: 1, payload: Schema.Struct({ name: Schema.String }) },
26 Effect.fn(function* (payload) {
27 yield* title(`Release ${payload.name}`);
28 const notes = yield* step("notes", { returns: Schema.String }, Effect.succeed("3 fixes"));
29 const answer = yield* ask("ship", {
30 title: `Ship ${payload.name}? ${notes}`,
31 choices: ["Ship", "Hold"],
32 });
33 if (Option.isNone(answer) || answer.value.choice !== "Ship") return yield* stop("held back");
34 return { shipped: payload.name };
35 }),
36);
37```
38
39Start it with `t3 workflow start release --input '{"name":"v1.4"}' --key v1.4`, then answer its question in the app. `T3`, `Effect`, `Schema` and `Option` are provided; a workflow file imports nothing from T3 or Effect. Name files with letters, digits, `-`, `_` and `.`; other names are skipped with a warning.
40
41Saving checks that the file loads, does not duplicate a workflow name and version, and does not remove a version with unfinished runs. A file that fails these checks keeps its last working version while the Workflows page (and the server log) shows why; other files are not affected. A change held back by unfinished runs goes in by itself once those runs end or are cancelled. Mistakes inside a workflow body surface when a run hits them and pauses. To change steps while runs are unfinished, add the new body under a higher `version` and keep the old one until those runs end.
42
43Dot-files and subfolders are ignored. Keep shared helpers in a subfolder and restart the server after editing an imported file.
44
45## Start and steer
46
47```sh
48t3 workflow start <name> --input '<json>' --key <key>
49t3 workflow list [--status paused]
50t3 workflow show <run>
51t3 workflow resume <run>
52t3 workflow cancel <run> [--reason '<why>']
53t3 workflow questions
54t3 workflow signal '{"choice":"yes"}' --run <run> --wait <name>
55t3 workflow signal '<json>' --workflow <name> --channel <channel>
56t3 workflow hooks
57t3 workflow store list
58t3 workflow store set <key> '<json>'
59```
60
61Every start needs a `--key`: starting twice with the same key returns the same run — even after a version bump — so retries do not duplicate work. Use `signal` with `--run` and `--wait` to answer a question or wake a run, or with `--workflow` and `--channel` to wake whichever run waits on that channel. A signal for a question that is no longer open is kept for a later wait rather than refused, so check `t3 workflow questions` first. Use `store` to read or change state kept between runs.
62
63## Triggers
64
65- **Schedules:** `every` runs on an interval, starting one interval after the workflow loads; `daily` runs at a local time of day (a time missed by more than 10 minutes while the server is down is skipped).
66- **Webhooks:** `t3 workflow hooks` prints each hook's path; prepend your server's address. The path contains the hook's secret, so share it only with the sender. A sender's retry that repeats its delivery header (such as GitHub's `X-GitHub-Delivery`) starts no second run, and bodies over 1 MiB are refused. A hook starts at most 60 runs a minute; requests past that get `429` and can be sent again a minute later. Organization policies blocking webhook tasks block workflow webhooks too.
67- **Issues and pull requests:** workflows can start on new issues or pull requests and read, comment on, or update them via **Settings → Source control & issues** — no webhook needed. T3 Code checks roughly once a minute, and only items opened after the workflow was first loaded start runs.
68
69## Follow runs in the app
70
71Open the Workflows page with **Open workflows** in the command palette of the web or desktop app; the entry shows once a connected server has workflows on. Filter by **Needs you**, **Running**, or **All** (skipped runs stay hidden unless toggled on), open child runs from their parent, and answer questions, resume paused runs, or cancel active runs (requires permission to operate threads). The issues and pull requests a run touched show as chips under its title and on the steps that touched them; a chip opens the item beside the run, in a tab next to any agent transcripts you opened.
72
73Top-level skipped runs, such as webhook deliveries a workflow chose to ignore, do not keep the payload they started with. Each workflow keeps its latest 500 of them and deletes older ones about an hour after they end; change the number in **Settings → Labs → Skipped runs kept** (0 keeps none), or set `"workflowSkippedRunsKept"` in `userdata/settings.json`. Runs that did anything else are never deleted. Once a skipped run is deleted, a start with its key or a webhook retry with its delivery header starts a new run.
74
75### Agent threads
76
77Each `agent` step runs in an ordinary thread, left out of thread lists (including `t3 thread list`). Open it from the run to watch it live, read its transcript, or send follow-up messages; the thread links back to the run.
78
79An `agent` step can launch a new thread with its own `workspace` (such as a worktree), `runtimeMode`, `interactionMode`, `title`, and typed `returns`, or continue an earlier step's thread. Runs can set their display name with `title(text)`. An `agent` step can also target a project on a [linked environment](remote-access.md#link-another-environment) (requires **Settings → Labs → Linked environments**); the run itself stays on the server that started it.
80
81### Failures, pause, and cancel
82
83A plain code step runs once unless it asks for retries. When a step fails, the run pauses there instead of losing earlier work:
84
85- **Code step failures** retry automatically after 5, 20, and 80 minutes by default, or immediately when you resume; only that step runs again.
86- **Agent failures** — when an agent ran and gave up or timed out — pause and wait for you to resume rather than retrying automatically. An agent that could not be started at all, for example because its environment was offline, retries on its own like a failed step.
87
88Cancelling a run stops its active agent turns and cancels child runs it invoked. A cancelled run cannot be resumed.
89
90## Limits
91
92- Runs live on the server that started them and only advance while it is running; use an always-on machine for schedules or webhooks you cannot miss.
93- Keep older workflow versions defined until their unfinished runs end or are cancelled.
94- Signals sent to a `channel` before a run waits on it are kept for 7 days by default.