AI is a first-class step
A pinned prompt version, an output schema and a cost budget. The engine enforces all three.
In design · open source · spec published
Weir is the workflow engine built for AI. Five kinds of step, one contract, budgets that are enforced and a full record of every attempt. It runs on Postgres and scales to zero.
Why it exists
Most workflow engines were built for code calling code. An agent is something else: it costs money every time it runs, it can be talked into things, and its output has to be checked.
Weir treats that as the normal case. A prompt is pinned. An output is validated. A budget is a limit, not a report. A person signs off where it matters, and the record shows who and why.
Five kinds of step
A step is done by a classifier, an agent, your code, a person or another system. All five share the same inputs, outputs, retries, timeouts and audit record, so the trail does not depend on who did the work.
- id: fix
kind: ai
prompt: fix-incident@7 # pinned, immutable
tools:
read: [scm.read_file, scm.search]
write: [scm.create_branch] # writes are listed by name
output: { schema: schemas/change.json }
budget: { usd: 15.00, minutes: 45 }
on_failure: block
Two mechanisms, five kinds. Decide, AI and deterministic steps run now: a worker claims the step and returns a result. Human and external steps wait: the step is parked, costing nothing, until someone returns its token.
Spend fewer tokens
Work goes to the cheapest tier that can do it. A larger model is used only when a smaller one cannot decide. This is built into the contract, so the cheap path is the default path.
Code. No model, no tokens.
The answer can be computed.
A small model returns one label.
The answer is one of a few known labels.
An agent on a small model with a lean context.
The work is simple, like replying to "thanks".
An agent on a large model, with tools.
The work needs judgement or several steps.
Every model call passes through one gateway. It picks a small or large model for each input, meters tokens against the attempt, refuses calls that would break the budget, and falls back when a provider fails.
Inbound events meet a rule first, which costs nothing. A classifier sees only what the rule lets through. A run starts only for what the classifier says is worth it.
Record what the router would have chosen while the usual model still runs. Compare quality and latency by label before you switch it on.
What makes it different
A pinned prompt version, an output schema and a cost budget. The engine enforces all three.
Decide, AI, deterministic, human and external steps share inputs, outputs, retries, timeouts and audit.
Budgets stop runs. Schemas reject outputs. Nobody approves their own request.
Prompt, transcript, tool calls, output, actor, cost and decision, on a log that cannot be rewritten.
Rules before classifiers, classifiers before agents. A large model is the last resort.
Versioned YAML, immutable once published. A new workflow needs no change to the engine.
Third parties resume a parked step with a token. Weir notifies them through signed hooks.
No cluster, no broker, no always-on server. When nothing is running, you pay for the database.
A fix counts only when the system that raised the problem confirms it has gone.
Add any MCP server. Agents reach tools only through Weir, with an allow-list on every step.
One installable unit per system: its connection, its events, its notifications and its tools.
Pipes
A Pipe connects one outside system to Weir. Install it once and use its parts in any workflow. Swap the Pipe behind a name and the same workflow runs against a different provider.
pipe: scm-github
version: 2.1.0
connection:
auth: oauth
sites: [api.github.com]
inlets:
- issue_opened
- pull_request_merged
tools:
read: [read_file, search]
write: [create_branch]
handlers:
- open_issue
- merge
A Pipe is not a pipeline. A Pipe connects a system; a workflow is what runs.
Governance
A workflow author cannot switch these off, and a worker cannot bypass them.
Versions are immutable. Each attempt stores a hash of the prompt it actually ran.
Every AI output is validated against its schema before the run moves on.
Spend is counted per attempt, step and run. Hitting the limit ends it.
The engine checks who the actor is. The requester cannot be the approver.
Weir makes every tool call on the agent's behalf, after the allow-list check.
If a server changes its tools after approval, its writes pause until someone reviews.
An unsure or unavailable classifier returns the default you declared.
Events are append-only, enforced in the database.
When things go wrong
Say what happens next when a step fails for good.
One in front of every model provider and third party.
Every try at a step gets a fresh, unguessable token.
Runtime
Weir is a stateless Go service on Postgres. Because workflows are data and step kinds are fixed, it stores the current step and each step's output, and never replays your code.
A step waiting on a person or a third party consumes nothing. When work appears, a wake-up message starts a worker; a scheduled sweep catches anything that was missed.
How it compares
| Capability | Weir | Temporal | Conductor | Step Functions |
|---|---|---|---|---|
| Workflows defined as data | Yes | Code | Yes | Yes |
| Pinned prompt versions and enforced cost budgets | Yes | Build it yourself | No | No |
| Approval with roles and escalation, in the open-source version | Yes | Build it yourself | Commercial edition | Build it yourself |
| Cheap classifier step with a safe default | Yes | Build it yourself | No | No |
| Self-hosted on Postgres alone, scaling to zero | Yes | No | No | Managed service only |
| Tool calls proxied with an allow-list per step | Yes | Build it yourself | No | No |
Based on our reading of each project's documentation in November 2026. Weir's column describes its design, not a released product.
Open source
Weir is designed as a small, stable contract with a reference engine, and many independent places to add value. A problem shared is a problem halved.
The definition schema, the event catalogue and the implementation guide.
Runs, the five step kinds, tokens, retries, failure policies, on Postgres.
The wake-up and sweep path, with a measured idle cost.
Budgets, the AI gateway, circuit breakers, the approval inbox.
The Pipe manifest, hooks, the tool proxy and the first source control Pipes.
A passing conformance suite, proven by a real platform running on it.
The spec is written. The best time to shape it is before it is frozen.
Links are placeholders in this preview.