Rhys Brett-Bowen Coding in the age of AI

Every Node Needs Its Own Runner

16 min

Confidence built and in use; the node-runner-as-unit argument is reasoned from the schemas rather than measured against a top-level-only design

“A distributed system is one in which the failure of a computer you didn’t even know existed can render your own computer unusable.” — Leslie Lamport (1987)

A slate track carries clay tokens through a line of sandstone gates; beside the track a paper ledger takes a mark at every gate, and one token that failed a gate is held at its edge rather than passing.

Every write-up of a multi-stage agent system shows you the topology. Boxes, arrows, four passes converging on a gate. None of them show the program that walks it, which is the one you will spend your time in.

The useful version of that program is smaller than people expect, and it is not at the top. Give every node its own runner — one stage, invocable on its own, against an input you recorded earlier, producing a validated output and a record. The thing that walks the whole graph is then composition, and most of the properties you want turn out to be properties of the small one.

This comes from a code reviewer built as scouts, triage stages, deep passes and writers — the build is Building an Agent Graph — but none of it is specific to review.

Bottom line up front

  • The unit is the node, not the graph. A node runner takes a recorded input, validates its output against the schema, and writes a record.
  • The graph runner owns the joins, and only the joins. Grouping, deduplication and anything else that reads across findings cannot be per-item, and that is where its real work is.
  • A node you cannot run alone is a node you cannot debug, tune or test. That is the whole argument, and the schema is what makes it possible.
  • “Retry once” then means something — the node runner is the retry unit, because it is the smallest thing that can be re-executed in isolation.
  • Record the raw output before parsing. It is the field everyone skips and the only one that makes a parse failure readable.
  • Check whether you need to write the graph runner at all. Durable execution engines already do crash recovery, retry and idempotency.

The node runner is the unit

A node has a typed input and a typed output. That contract is also an invocation boundary. Anything that can produce the input can run the node, and the stage does not care whether that was the previous stage, a test fixture, or you at a terminal with a saved payload from last Tuesday.

Build it so all three work. You get four things, and they are the four things that make a graph tractable:

  • Re-run. Feed it yesterday’s recorded input and watch it again. Without this, reproducing a bad finding means re-running everything upstream of it and hoping the non-determinism lands the same way, which it will not.
  • Inspect. One stage, one input, one output, nothing else in the frame. Most “the graph did something strange” turns out to be one node doing something ordinary with an input you did not expect it to get.
  • Test. A fixture is a recorded input plus the output you expect — where “input” has to mean everything the stage reads, including the model and its settings, any retrieved context, and the prompt and schema versions. Record less than that and the fixture is not reproducible, it just looks it. Graph-level tests are possible too; this is simply the level where a failure tells you which stage caused it.
  • Tune. A node has a narrower objective than the graph — a scout is tuned for recall, a deep pass for precision — and you cannot optimise against that objective without running the node by itself. See Tune the Prompt Before You Split It.

If a stage can only be reached by running the four passes above it, you do not have a node. You have a region of a monolith with a schema drawn on it.

You now have stages, schemas and a failure ladder. Nothing yet executes them. The runner is the program that does, and it is the part of the build nobody writes down and everybody debugs at two in the morning.

Walk one finding end to end before you write any of it. For this reviewer a single finding travels: context discovery → a scout raises a lead → triage keeps or drops it → dup-triage groups it with leads of the same shape → a deep pass confirms or refutes → a writer turns a confirmed verdict into prose → the dedup pass merges it with anything equivalent. Seven boundaries. The runner owns every one of them, and at each it does the same four things: validate the envelope against the schema, classify any failure on the ladder, decide whether to retry, and record what happened.

Define the retry unit, or “retry once” means nothing. That is the question the failure policy in the failure ladder leaves open. The unit here is one stage invocation — not the pass, and not the run. For most stages that is one item. It is not when a stage batches, and several here do: the deep pass takes items in sixes and the demo harness sends every snippet in one call. A batch is one invocation, so a bad item inside it cannot be retried alone without splitting the batch, which changes the thing you are retrying. Decide it per stage, because the batched case quietly re-bills nine good items to recover one. Retry the pass and you re-bill every item that already succeeded, which on a wide scout is most of them. Retry the run and you have thrown away an hour to recover one bad JSON parse. Per item is also the only unit at which the ladder is actionable. envelope_parse is worth one retry, because it is usually transient. item_invalid is worth none: the model produced a well-formed answer you rejected, and it will produce it again.

Record enough to resume, which is more than enough to debug. Per item, per stage: the stage id, the schema id and version it validated against, the raw output before parsing, the failure kind if any, and the cost and wall-clock. The raw output is the one people skip and the one you need — a result_parse failure is unreadable without the bytes that failed. The longer reason to keep it is The Raw Is the Trust Boundary: once the raw is gone, every downstream claim about what the model said is a claim you cannot check.

A run is resumable exactly as far as you persisted it. Key each result on the stage, the item, and a hash of everything that determines the output: prompt, schema version, model and settings, and the code version of a mechanised stage. People reach for the prompt alone, and then an edited schema or a swapped model silently serves answers produced by the previous one, which is worse than having no resume at all.

Two honest limits on that key. Item identity is not stable across a join — after dup-triage merges three leads into a group, the thing you are keying has no single predecessor, so the join needs its own identity rule rather than inheriting one. And a key is not crash recovery. It tells you what already finished; it says nothing about a write that was half-flushed, a call that was in flight when the process died, or whether a retried attempt double-counted. Those need atomic record writes and an explicit in-flight state, and if you want the properly-worked version of this, read how a durable execution engine defines replay before you invent your own.

Fan out per item on the map stages, and treat the joins separately. Most stages are sequential for a given finding and independent across findings, so the concurrency lives on the item axis. A runner that parallelises passes instead serialises each pass internally, and leaves most of the wall-clock on the floor.

But not every stage is a map. Dup-triage groups leads of the same shape, and the dedup pass merges equivalent findings across all four passes — both read across items by definition. Those are joins, and they need three things a map stage does not. A rule for when the group is complete, so the stage can run at all. An item identity that survives the merge. And a barrier where the fan-out has to rejoin. Getting this wrong is the commonest way a graph runner produces almost-right output: a dedup that ran before the last scout finished will cheerfully merge what it has and drop the rest. If you only internalise one thing here, it is that the per-item model is a map model, and your graph is not all maps.

All of this is mechanism rather than judgment, which is the tell that it belongs in code and not in a prompt — see mechanising. It is also the part cheapest to get wrong invisibly: a runner with no per-item record still produces findings, and you will not discover what it dropped until you go looking for something it never kept.

What already exists, and where it stops

Worth knowing before you write anything, and it is shorter than the ecosystem’s marketing suggests.

DSPy is the closest thing to this guide’s model — signatures, modules and optimizers are a typed contract per stage, composable units behind them, and a compiler that tunes the prompts. It is a programming model first, and the gap is narrower than I first wrote: it has request-level retries, typed errors and usage tracking. What it does not give you is the durable half — resume across runs, a barrier for join stages, circuit breaking per stage — which is the part an orchestrator is actually for. Durable execution (Temporal, Restate, DBOS) is the other half — crash recovery and idempotency, each step keyed to its position in workflow history, which is the properly-specified form of the resume key above. dspy-temporal composes the two, if you want to see it done. Generic DAG runners (Airflow, Dagster, Prefect) have had typed tasks, retries and backfills for years. And if what you want is a graph described in a file rather than in code, Haystack serialises pipelines to YAML with branching and cycles, while Langflow and Flowise make the graph an exportable document.

The PyTorch instinct is a good one, incidentally: a node behind a typed contract, composed and swappable, is nn.Module. What does not carry over is autograd — there is no gradient through a model you did not train — so composition gives you structure and nothing about optimisation. The optimiser has to be an outer loop over measurements, which is why all of this hangs off the eval corpus.

Keep the division of labour even if you adopt none of them: the programming model owns the contracts and the tuning, the runtime owns time, failure and money. Build one thing that half-does both and you get a purpose-built runner, hard to reuse and hard to reason about.

The one thing no engine can decide for you

The retry policy. An engine will retry whatever you tell it to and has no opinion about which failures deserve it, because in ordinary software the answer is “the transient ones” and it can usually tell which those are.

A model stage breaks that. envelope_parse and item_invalid are both “the stage returned something unusable” and they are indistinguishable at the transport layer, so nothing underneath you can tell them apart. Your taxonomy can.

Retry garbled output once; do not retry a well-formed answer that missed the schema. Garbled output is usually transient. An answer that parsed and then failed validation is a considered response you rejected, and asking again mostly buys you the same one at double the price.

Treat that as a default rather than a law — a malformed envelope can recur, and a fresh generation can fix an invalid item — and then check it, by recording the outcome of every retry you make. The hit rate per failure kind is a cheap number and it tells you whether your policy is earning anything. I have not collected it, and when I went looking I found out why. My own sweep data records that a dispatch ran and whether it came back, and nothing else. Nothing marks a retry, so nothing marks whether one worked — and the runner only learned to tell refusal from overrun from truncation weeks later, so there is no version of that data that could answer the question. The number is cheap to collect, and only if you instrument for it first. Which is the whole point of naming the kinds, and I am the worked example of missing it. What does not change either way is that the decision needs your schema’s meaning, and a generic engine cannot make it for you — so name the kinds and hand it a policy.

Write one, on top of something

Having surveyed all that, my actual advice is: write your own runner. It is a smaller job than the ecosystem makes it look. Write it and you get exactly your failure taxonomy and exactly your cost accounting, rather than a general vocabulary that nearly fits.

The surface is about a page. The decisions behind it are the actual work. Here they are as questions to settle before you write anything: each one is a line of the runner, and each has a wrong answer that will not announce itself.

Invocation

  • What is one invocation — a node and one item, or a node and a batch? The answer sets your retry unit, your concurrency and your cost granularity at once.
  • Do you validate the input as well as the output? A node callable from a test, a replay and the graph has three sources of malformed input, and only one of them is a stage you control.

Failure

  • Do you classify by exception type or by a taxonomy you name? The exception tells you what the transport saw; only a taxonomy tells you what it means.
  • Which kinds get a retry, how many, and do you back off between them?
  • What is the timeout, per stage — and does a timeout retry, or fail closed? They are different policies and the default is usually neither.
  • How many consecutive failures across items before you stop calling a stage at all, and what happens to the items you skip?
  • Who owns the retry when a node runner is called by a graph runner that also retries? Two layers each retrying twice is four calls and nobody intended it.

Record

  • What goes in, and is it written durably before the call returns or after? Before costs a write on every attempt; after loses the attempt that killed the process, which is the one you wanted.
  • Does a retried attempt append a second record or overwrite the first? You cannot compute a retry hit rate from overwrites.

Resume

  • What is in the key besides the prompt — schema version, model, settings, code version of a mechanised stage? Anything you leave out is something that can change while the cache quietly says “already done”.
  • What is “the item” after a join has merged three of them into one? The identity has to come from somewhere, and inheriting it from the first member is a decision, not a default.

Shape

  • Which stages are maps and which are joins, and what is the barrier that tells a join its input is complete?
  • Where does a permanently failed item go, and who looks there? A dead-letter nobody reads is a log line with extra steps.

Settle those and the code is a page. Leave them open and you will write a runner that looks right, because every one of them has a plausible default that is wrong for somebody.

Write it on top of a programming model rather than from nothing. DSPy gives you the typed contracts and the optimiser; you add time, failure and money, which is the half it does not cover. That division is the thing to preserve: the programming model owns the contracts and the tuning, your runner owns what happens when a call takes ninety seconds and then returns nothing. dspy-temporal is one worked example of the same composition if you want to see it done against a full engine.

Reach for a full orchestrator — Temporal, Dagster, Prefect — when your constraints actually demand one: runs measured in hours, work spread across machines, or a graph that has to survive a deploy mid-run. None of those are true here, which is the whole of my reason for not using one.

I should not dress that up as an argument that engines cost you something. They do not: an item can be an engine task, your application code can supply the taxonomy and the records, and LangGraph documents node-level retries and checkpointing directly. I have not run the comparison, so the honest claim is that writing one was cheap at this size and taught me the failure modes — not that adopting one would have lost me anything.


How sure I am: the node runners, the records and the resume key are built and in use, and re-running a single node against a saved input is how most debugging here actually happens. A cross-family read of this post found seven things wrong with it, and the biggest was structural. I had written that stages are independent across findings — false for the two stages in my own graph that read across them. Dup-triage and dedup are joins, the per-item model is a map model, and the fan-out rule, the resume key and the claim that the graph runner owns almost nothing were all downstream of that mistake. The section on joins exists because of that read. Two things I would flag. The argument that the node is the right unit is reasoned from the schemas rather than measured against a top-level-only design — I have not built both and compared. And the framing arrived late. A prior-art search while writing this turned up that durable execution is a mature field, and that my resume key is a narrower version of an idempotency key tied to position in workflow history. The gaps named above are gaps in my runner too — I have timeouts, no circuit breaker, and a dead-letter channel that is a log file. The config-driven version of this runner is an intention, not a thing — the one I actually run is purpose-built and knows its own stages. The survey of what already exists came from a prior-art search done while writing. It did not change the recommendation — write one — but it did change what I think you should write it on top of, and it is where the timeout/circuit-breaker/dead-letter list comes from.

Sources

  • Durable execution — Temporal, Restate and DBOS, and the pattern of per-step idempotency keys tied to position in workflow history so a restarted process replays to where it stopped.
  • Orchestration frameworks — LangGraph and similar, which supply the graph and the checkpointing together rather than leaving the walk to you.
  • Resiliency patterns for agent pipelines — timeouts, backoff, circuit breakers and dead-letter queues, standard in that writing and absent from my first version.
  • My own build: the stage topology and the six-kind failure ladder in Where to Cut, and the runner in its place in the sequence in From Rules to Runs.

Related: Building an Agent Graph: Where to Cut — where the schemas and the failure ladder come from; From Rules to Runs — the section this post expands, in its place in the build; Tune the Prompt Before You Split It — what running a node alone is for; A Pipeline Is What It Refuses to Forward — what crosses a boundary and what must not.