Sebastiano Druda

← Back to writing

Guide / AI & Automation

The Best LLM Workflow Has an Exit Ramp

An LLM workflow needs a route for uncertainty, invalid output and exhausted retries. Design review queues and deterministic checks before automating decisions.

Imagine a workflow that reads a supplier document, extracts product attributes and prepares an import. Most records look straightforward. One document describes two package sizes in the same paragraph, gives a weight without a unit and uses a product name that resembles an existing SKU.

An endlessly helpful automation might keep trying until it produces a complete row. A more useful workflow might stop, preserve the ambiguity and place the record in a review queue. The second result can look less impressive in a demo while being much safer to operate.

Good automation knows when it is no longer the right tool.

An exit ramp is a designed transition from model-assisted work to another mode: deterministic processing, human review, a request for missing information or an explicit failure. It should be part of the original workflow, rather than an emergency measure added after the first uncomfortable output.

Define the handoff before the prompt

Start by deciding what the model is allowed to propose and what can be accepted automatically. In the supplier example, extracting a candidate description is different from deciding that two records represent the same sellable product.

A proposed record might contain the extracted value, its source location and an explicit list of unresolved fields. Deterministic code can then check required units, permitted categories and known identifiers. Ambiguous identity can remain a review decision instead of being converted into a convenient guess.

This division makes the prompt easier to write. The model does not have to pretend every input supports a complete answer. It can return partial evidence in a shape that the rest of the workflow understands.

The handoff also needs ownership. “Send to human review” is incomplete unless somebody can find the item, see why it stopped and record a decision. A queue with no expected resolution path merely stores uncertainty more neatly.

Structured output is a boundary, not a truth detector

A schema can require an array, a permitted status or a particular set of fields. It cannot establish that an extracted number was present in the document or that the chosen category matches the business meaning.

OpenAI’s Structured Outputs documentation describes schema-constrained responses and separate handling for refusals. That is useful infrastructure for an application boundary. It does not remove the need to handle incomplete work, unsuitable input or a structurally valid but incorrect answer.

For the hypothetical importer, weight: 12 is structurally simple and semantically incomplete without a unit and product context. A model can satisfy a numeric field while leaving the real question unresolved. Make the uncertainty representable rather than forcing the system to encode it as a misleading value.

A helpful test fixture is an input that cannot support the requested output. The expected result should be a controlled unresolved state. If the workflow accepts a confident invention, the schema has not protected the decision that matters.

Deterministic work should remain deterministic

Once the model has proposed a recognized unit and a valid quantity, converting between agreed representations may be ordinary code. Known category identifiers, mandatory fields and duplicate operation identifiers also belong in explicit validation where possible.

Sending every downstream step back to the model makes the workflow harder to reproduce and explain. It also broadens the set of places where an unsupported interpretation can enter the result. Use the model where language or incomplete evidence actually requires that flexibility.

This is a design preference grounded in inspectability, not a claim that deterministic code cannot be wrong. A conversion function still needs tests and a correct specification. Its advantage is that the same accepted input can follow a clear, reviewable rule.

A useful pipeline might therefore look like this:

source document
→ proposed extraction with provenance
→ deterministic validation
→ accepted record or review item
→ controlled publication

The final publication step should not depend on whether a generated explanation sounds persuasive. It should depend on the acceptance conditions the workflow has made explicit.

Confidence needs a relationship to consequences

A number labelled confidence is easy to display and easy to overinterpret. Before using it to automate a decision, ask how it was produced and how its behavior has been evaluated on the cases that matter.

For the catalogue example, a wrong descriptive adjective and a wrong package quantity carry different consequences. A single acceptance threshold applied to the entire record can hide that difference. Some fields may be safe to suggest while others require direct evidence or explicit approval.

I would begin with field-specific acceptance rules and representative examples rather than a universal confidence cutoff. Record which proposals were accepted, corrected or rejected and why. That evidence can support later decisions about automation scope.

The AI evaluation article explains why a compelling demonstration is not enough. An exit policy should be evaluated on difficult and ambiguous inputs, not only on the documents that make the model look fluent.

Review should preserve context instead of creating detective work

A reviewer needs the original passage, the proposed interpretation and the failed rule. Asking someone to approve an isolated value without its source encourages another round of guessing.

The interface should make the relevant difference visible. If the model proposes kilograms while the document mentions grams elsewhere, the reviewer should see both pieces of evidence. If the source is simply silent, show that absence rather than inventing a reason the value might be correct.

A review queue is useful when it preserves the decision, not merely the rejected output.

Record the outcome in a way that supports the next step. Was the value corrected, the source replaced, the item deferred or the mapping rule changed? Those are different resolutions. A generic “approved” flag may be insufficient for reconstructing what happened later.

Keep private source documents within the intended access boundary. Better observability does not mean copying complete documents into every notification, analytics event or error log.

Retries need a hypothesis

Trying the same request again can be reasonable after a transient transport failure. It is less compelling when the input lacks information the model needs. Another attempt does not create a missing product identifier.

An agent loop should therefore distinguish failure categories. A temporary unavailable dependency may justify a bounded retry. A schema mismatch may justify one constrained repair attempt. An unresolved identity should leave the loop and request evidence. These are proposed policies to adapt to the task, not universal retry counts.

Each retry should answer what has changed or what new information it expects to obtain. If nothing changes except the hope of a better answer, the loop needs a budget and an exit condition.

A useful execution record includes attempt count, reason for repetition and final disposition. That makes an exhausted loop distinguishable from a deliberate referral to review. Both can stop automation, but they reveal different problems in the workflow.

The fallback can be a smaller useful result

Stopping full automation does not always require abandoning the task. If a source supports a description but not a reliable product identity, the workflow can preserve the description as a draft while withholding the import. If document extraction fails, the original file can remain available for manual processing.

Design the smaller result carefully. It should not resemble a completed publication when it is only a proposal. Status and allowed next actions need to agree, especially when another automated step might consume the output.

This is related to keeping judgment in automation. The goal is not to place a human in every loop for symbolic reassurance. It is to reserve consequential ambiguity for a mode of work that can obtain the missing context and take responsibility for the choice.

Make stopping a normal outcome

A workflow that treats every review item as a failure will encourage people to hide uncertainty. A workflow that treats every item as reviewable may provide little useful automation. The design problem is to distinguish routine acceptance from cases where proceeding would make a stronger claim than the evidence supports.

Measure useful outcomes: accepted records that remain correct, reviews resolved with enough context, and repeated failure categories that suggest a better upstream process. Raw completion rate alone can reward the very guessing the exit ramp was meant to prevent.

Before shipping an LLM workflow, walk an ambiguous case all the way through its stopping path. Confirm that the source survives, the next owner is clear and publication remains controlled. A reliable exit is part of the product, even when the happiest demonstration never uses it.

Sources

  1. OpenAI: Structured outputs — checked 2026-10-13

Topics

13 / Essay

Context Engineering Beats Prompt Tricks

Better AI-assisted work starts with approved decisions, useful evidence and clear limits. A practical approach to context that survives real project changes.

prompting context engineering · llm workflows · 7 min