docs/user/workflows.md
Workflows
Workflows (Labs) are durable TypeScript scripts that chain agents, code steps, schedules, webhooks, issue/PR triggers, and human approvals into multi-stage runs that survive server restarts. Each completed step is checkpointed so restarts resume where they left off.
Use a scheduled task for a single prompt on a timer or webhook; use a workflow for multi-stage pipelines (e.g., triage → fix → approval → release).
Enable workflows
Turn on Settings → Labs → Workflows on the server that will run them (or set "workflowsEnabled": true in ~/.t3/userdata/settings.json on headless servers). Existing runs pause while disabled and resume when re-enabled.
Create a workflow
Place .ts files in ~/.t3/workflows/ (or the path in T3CODE_WORKFLOWS). The server watches the folder and hot-reloads valid edits.
- With an agent (recommended): Copy the
t3-workflowsskill into your agent's skills folder (e.g.~/.claude/skills/or~/.agents/skills/) and describe what you want. - Directly: Edit files in
~/.t3/workflows/or use Definitions on the Workflows page (Open workflows in the command palette; saving/deleting in the app requires terminal access).
Example (~/.t3/workflows/release.ts):
| 1 | const { workflow, step, ask, stop, title } = T3; |
| 2 | |
| 3 | export default workflow( |
| 4 | "release", |
| 5 | { version: 1, payload: Schema.Struct({ name: Schema.String }) }, |
| 6 | Effect.fn(function* (payload) { |
| 7 | yield* title(`Release ${payload.name}`); |
| 8 | const notes = yield* step("notes", { returns: Schema.String }, Effect.succeed("3 fixes")); |
| 9 | const answer = yield* ask("ship", { |
| 10 | title: `Ship ${payload.name}? ${notes}`, |
| 11 | choices: ["Ship", "Hold"], |
| 12 | }); |
| 13 | if (Option.isNone(answer) || answer.value.choice !== "Ship") return yield* stop("held back"); |
| 14 | return { shipped: payload.name }; |
| 15 | }), |
| 16 | ); |
T3,Effect,Schema, andOptionare globals—no imports needed.- Filenames may use letters, digits,
-,_, and.. Dot-files and subfolders are ignored (put shared helpers in a subfolder; edits to them reload the workflows that import them). - Versioning: Keep older workflow versions defined while they have unfinished runs; bump
versionto deploy new steps alongside active runs.
CLI commands
| 1 | t3 workflow start <name> --input '<json>' --key <key> |
| 2 | t3 workflow list [--status paused] [--tag <tag>] [--subject <url or id>] |
| 3 | t3 workflow show <run> |
| 4 | t3 workflow resume <run> |
| 5 | t3 workflow cancel <run> [--reason '<why>'] |
| 6 | t3 workflow questions [--kind <kind>] |
| 7 | t3 workflow signal '{"choice":"yes"}' --run <run> --wait <name> |
| 8 | t3 workflow signal '<json>' --workflow <name> --channel <channel> |
| 9 | t3 workflow withdraw --run <run> --wait <name> [--reason '<why>'] |
| 10 | t3 workflow hooks |
| 11 | t3 workflow store list |
| 12 | t3 workflow store set <key> '<json>' |
--keydeduplicates starts across retries and version bumps.signalanswers an open question or wakes a channel wait (signals sent before a channel wait are buffered for 7 days by default).withdrawcancels an open question soaskreturnsNone.storereads/writes shared state persisted between runs.
Questions, tags, and subjects
- Question kinds & tags: Declare
asks: { kindKey: "Label" }in workflow options and passkindtoask(...)to filter open questions under Needs you (andt3 workflow questions --kind <kind>). Usetags([...])to label runs for filtering. - Rich choices & links: Pass
links: [{ label, url }]and choice objects{ value, description, requireReason }to require an explanation before answering. Answers recordansweredAtandansweredBy. - Subjects: Call
subject(issueOrPrOrThreadOrUrl)(or pass{ subject }tostart(...)) to display and link the target item in run lists, issue/PR views, andt3 workflow list --subject <url>. An issue or pull request view, and--subject, also show the runs that opened or touched that item, not only the run it is the subject of.
Concurrency limits
- Whole-workflow cap: Set
concurrency: 4in workflow options. - Step pools: Wrap a section in
within("builders", { limit: 4 }, ...)(limit: 1acts as a lock). Waiting runs show as Queued in FIFO order; resumed runs re-acquire their pools first. - Avoid nesting
withinon the same pool name (or a workflow's own concurrency pool), and avoid holding a lock acrossinvokeif the child needs the same pool. Step names starting with@pool:are reserved.
Triggers
- Schedules:
everyruns on an interval;dailyruns at a local time of day (skipped if missed by >10 minutes while offline). - Webhooks: Run
t3 workflow hooksto get each hook's secret path (prepend your server URL). Deduplicates retries by delivery header (e.g.X-GitHub-Delivery), rejects bodies >1 MiB, and rate-limits to 60 runs/min (429). Blocked if managed policy disables webhooks. - Issues & PRs: Triggers automatically on new issues or PRs via Settings → Source control & issues (polled ~every minute; only items opened after the workflow first loads).
Follow runs, agent threads, and failures
Open Open workflows from the command palette (web/desktop) to filter Needs you, Running, or All, inspect agent threads, answer questions, resume, or cancel runs.
- Agent steps: Each
agentstep runs in a regular thread (hidden from sidebar lists) that you can open live from the run. Supports customworkspace,runtimeMode,interactionMode,title, typedreturns, and linked environments. - Retries & pausing: Failed code steps auto-retry after 5, 20, and 80 minutes (or immediately on Resume). Failed or timed-out agent steps pause for manual resume (offline-start failures auto-retry). Cancelling stops active agent turns and child runs permanently.
- Skipped runs: Up to 500 skipped top-level runs are kept per workflow (configurable via Settings → Labs → Skipped runs kept or
"workflowSkippedRunsKept"insettings.json). - Always-on requirement: Runs only advance while the server that started them is online.