Skip to content
The architecture decision

AI agent workflows: where should the judgment live?

An agent re-decides the work on every run, so the run that comes back wrong is the one your customer already has. Use an agent when discovering the path is the task. When the steps are known, let AI write the workflow once and let code run it every time after that.

Choose the control flow, not the label.

An AI step does not automatically make a workflow an autonomous agent. The useful distinction is who decides what happens next.

You know the route.

Fixed workflow

You describe the process and AI writes the branches and actions as code. Inputs can change without asking a model to plan the process again.

Best for: scheduled reports, record syncs, validation and known approval rules.

Trade-off: an unfamiliar case needs a branch the AI writes and you review.

The route is the work.

Agent

A model chooses tools and next steps from feedback. It can investigate a problem whose path is not known in advance.

Best for: research, debugging and exploratory tasks with clear stopping conditions.

Trade-off: variable steps, latency and cost; constrain tools and escalation.

Judgment in a bounded step.

Hybrid

A workflow owns the process. A model classifies, extracts or drafts; code validates its result before acting.

Best for: triaging messages, processing documents and routing leads.

Trade-off: model errors still exist. Invalid or ambiguous output needs a safe route.

These are architecture choices, not hosting categories. Agents can run in the cloud and call scripts. A fixed workflow may call a model, or run with no model call at all.

Worked example · customer email triage

Let AI read the message. Let code own the consequences.

An incoming support email says “I was charged twice.” That needs interpretation. Choosing the billing queue, validating the customer ID and calling the ticket API should follow explicit rules.

  1. TriggerReceive email

    Keep the message ID and original text.

  2. AI judgmentClassify intent

    Return a category and evidence from the message.

  3. Code gateValidate & route

    Allow known categories; send ambiguity to review.

  4. API actionCreate ticket

    Use a stable source ID to guard against duplicates.

A hybrid pipeline: one bounded judgment, then explicit checks and actions. This is a design example, not a preconfigured template.

The model proposes; it does not authorize.

Treat the email and model response as untrusted data. A “billing” classification can route a ticket; it should not authorize a refund.

Unknown is an expected outcome.

Validate output shape and allowed values. Missing customer IDs, conflicting evidence or an unsupported category go to a review queue rather than a guessed action.

Test the messy cases.

Try a clear billing request, an ambiguous message, malformed output and delivery of the same message twice. Check the downstream records, not just the model’s answer.

Count the work. Then compare the bill.

There is no universal “agents cost X times more” rule. Measure one representative process under the plan and model you would actually use.

Total operating cost = platform + model usage + external services + operations time

Platform

Estimate executions, schedules and retries. Vendors meter runs, tasks, credits or compute differently; compare the same workload, not just the headline plan.

Model usage

Count input and output tokens for each model call. An exploratory loop may need several turns; a hybrid may use one bounded call; a rule-only path may use none.

External services

Include API fees, storage and tools. An agent that delegates to a script still has the costs of that script and its services.

Operations time

Budget for reviewing exceptions, investigating failures and maintaining connections. Measure latency and accuracy alongside spend.

See Whenever’s published pricing

Fixed code is not frozen reality.

Repeatable control flow is useful. It is not a promise that the outside world will stand still.

Replay needs boundaries

Whenever exposes named steps and runtime-provided time and randomness. Use those boundaries as documented; do not read Date.now() or Math.random() directly in workflow logic.

Fresh calls can produce fresh answers

A new API read can return changed data. A model call can produce a different answer. Fixing the workflow code does not guarantee identical results across fresh executions.

Retries are not exactly-once delivery

An external write can succeed before its response is lost. Design idempotency keys, duplicate checks or reconciliation appropriate to the destination API.

Portability still takes engineering

Readable TypeScript makes the logic inspectable. Moving it to another runtime can require replacing integration ports, trigger registration and execution semantics.

A few useful answers

What is an AI agent workflow?

The phrase is used for both model-directed agents and predefined workflows that include AI steps. Ask who chooses the next action: the model, explicit code, or a combination. That distinction tells you more about control, testing and cost than the label.

When should I choose an agent instead of a workflow?

Choose an agent when discovering the path is part of the task, such as investigating an unfamiliar bug or researching a question. Define allowed tools, a budget, stopping conditions and escalation. If the path is already known, start with a workflow.

Can a workflow use AI without becoming autonomous?

Yes. A fixed workflow can call a model to classify a message or draft text, then validate the result and continue through predefined branches. This bounded hybrid keeps judgment separate from permission to take an action.

Does fixed workflow code guarantee identical results?

No. External data can change and fresh model calls can vary. Replay also depends on the runtime’s step boundaries. External side effects need their own duplicate prevention or reconciliation; fixed code alone does not provide exactly-once delivery.

Does an agent need my laptop to stay on?

Not necessarily. Agents can be self-hosted or run on managed cloud infrastructure, and can invoke scripts. Hosting and scheduling are separate questions from whether a model or code controls the next step.

Sources & further reading

Sources reviewed September 24, 2026.

Keep the judgment. Let AI write the rest.

Describe one repeatable business process and AI writes it as a workflow code runs. Add a model step only where interpretation genuinely helps.