Building AI products

Why agent workflows need a graph, not a queue

Viaknox · ·1 min read Building AI products
Ink isometric drawing of a city block where an aqua track links a dozen small stations into a graph, with one operator approving a route at a desk

The first agent we put into production ran for eleven days before it charged a customer twice. Nothing in the logs looked wrong. The model had done exactly what it was asked, twice, because the process that asked it had restarted halfway through a step.

What a queue cannot tell you

A queue knows that a message was delivered. It does not know that the message was step four of nine, that step three produced a document the model now depends on, or that step four had already called a payment API before the worker died.

We tried to make it know. Every message grew a header with the run id, the step number, the hash of the previous output. Within a month the headers were the system, and the queue was a slow, expensive way to move them around.

What a graph gives you

A graph of typed steps makes three things explicit that a queue leaves implicit.

Order and dependency. Step four cannot start until step three has a recorded result. That sounds obvious; it is not what most agent loops actually enforce.

Idempotency. Each step has a key derived from its inputs. A retry with the same key gets the same result without calling the model or the API again.

An audit trail you can read. When a customer asks why something happened, you walk the graph. Every node has the prompt, the response, the tool call and the timestamp.

const run = graph()
  .step('fetch-invoice', fetchInvoice)
  .step('match-po', matchPO, { after: ['fetch-invoice'] })
  .step('charge', charge, { after: ['match-po'], idempotent: true });

What it cost us

Building this took longer than bolting headers onto a queue. It also ended the duplicate charges, and it turned “what did the agent do” from an afternoon of log archaeology into a page.

That is the trade we would make again, and it is the reason GraphSmith exists.

Questions about this article

Does this mean queues are bad?

No. Queues are excellent at moving work between services. They are the wrong place to store the state of a multi-step agent run, which is what we tried to make them do.

Is GraphSmith a replacement for Temporal or Airflow?

No. It sits at the level of a single agent run and can be hosted inside those systems. It cares about steps, their inputs and outputs, and what happens when a step fails.

What does "never duplicates work" mean in practice?

Every step has a deterministic key. If a crash happens after a step completed but before its result was recorded, the retry recognises the key and reuses the result instead of calling the model again.

Sources

  1. Temporal — Workflow durability
  2. Anthropic — Building effective agents

Try GraphSmith.

GraphSmith is a free, open-source tool that generates AI agent workflows that survive crashes, never duplicate work and don't hallucinate code.

GraphSmith on viaknox.com →
GraphSmith · by Viaknox

GraphSmith is a free, open-source tool that generates AI agent workflows that survive crashes, never duplicate work and don't hallucinate code.

Tags: agentsGraphSmithreliability