(Notes)

Guardrails for AI Workflow Automation: The Model Writes Text, Code Decides Amounts and Specs

The model writes text and creative copy; code decides amounts, specs, permissions and sending. Validate output before any action, cool down after failures, and put a human approval step on irreversible actions.

Polish Design engineering team・2026-12-01

Contents

The core split in AI workflow automation is simple: the model writes text and creative copy, and code decides amounts, specs, permissions and sending. The split applies to any flow where model output triggers an action, such as sending an email, creating a quote, changing a record or posting a notification, and it is where a review of enterprise AI agent adoption should start.

Anthropic, 2024 separates two kinds of systems. Workflows orchestrate models and tools through predefined code paths, while agents let the model direct its own process and tool usage. Most quoting, support and review flows inside a company are workflows. The same article advises finding the simplest solution possible and adding complexity only when needed. This article covers the guardrails the development team applies when wiring an AI workflow into business systems, as in its AI adoption and development projects.

Division of labor: the model writes text, code computes amounts and specs

Every field in an AI agent workflow has a different cost when it is wrong, so the first step is deciding which side owns which field. Take an online catering proposal as an example. The model only drafts the plan name and description. The pricing method, per-person price and add-on services come from the back-office spec, the backend overrides the matching fields in the model output, and the number of courses is trimmed to the spec limit. The diagram below shows how data moves across three zones.

Fig. 1The model returns only text, and the rule layer overrides amounts and specs

Model provider

  • Language modelDrafts plan names and descriptions from the prompt
Prompt and candidate dishesDraft text

Development team's server: rule layer

  • Pre-filter and promptsSQL pre-filters candidate dishes; prompts are split into sections and versioned
  • Override and trimOverrides price and add-ons from the back-office spec, trims course count
Overridden planSpecs and rules

Business systems and outbound actions

  • Back-office specPricing method, per-person price, add-ons, course limit
  • Proposal and notificationSaves the proposal, sends the notification

Fields kept on the code sidePricing method, per-person price, add-on services and the course limit are never decided by the model.

Online catering proposal as the example

Candidate dishes are not handed to the model as a full list either. Code first uses SQL to infer the season from the date, decide indoor or outdoor from the venue, and judge from the description whether a dish is vegetarian. Only the pre-filtered set goes to the model. Prompts are managed in sections, every edit leaves a version, and a rollback is available when needed. The result is that plan names vary while prices and specs stay consistent with the back office. For the case, see Cooking Monsters' online catering proposals, and for the process, see how an online catering proposal system works.

The basis for this split is LLM05:2025 Improper Output Handling from OWASP, 2025. When model output reaches downstream components with insufficient validation, sanitization and handling, the risk travels into the backend. The document recommends treating the model as an ordinary user, applying zero trust, and validating what the model returns to backend functions. Override rules put that recommendation into code.

A team member plugs an orange cable into a port on a blue server rack

Output constraints: structured, quoted from the source, checked by a second reader

Model output can only be checked by code if its format is fixed. When extracting data such as rules and eligibility conditions, the development team uses structured output with three added checks.

  • Every extracted value carries a quote from the source. Code verifies that the quote appears in the source and that the number appears in the quote. An and or an or that the source does not state is not added.
  • A second reviewer rereads the result, with a prompt that says to assume the previous reader made an error and to reread row by row. The record is accepted only when the code checks on both passes succeed.
  • When data is refreshed, a diff tool finds what changed, only the changed parts are redone, and code applies the rest directly.

Rows that still need a human eye are flagged and collected into one table for the responsible person. Even a change limited to the English in parentheses counts as a change, because the quote must appear verbatim in the source and may no longer match once the English is removed.

Action permissions and human approval

Once model output can trigger an action, permissions become the source of risk. LLM06:2025 Excessive Agency from OWASP, 2025 splits the root causes into three: excessive functionality, excessive permissions and excessive autonomy. The recommendations include minimal extension of permissions, human approval for high-impact actions, and placing authorization in downstream systems instead of letting the model judge whether an action is allowed.

In practice, list every field in the flow and look at what happens when that field is wrong. The diagram below sorts fields into three paths by consequence.

Fig. 2The consequence of a wrong field decides whether it goes to the model, to code or to a person
  1. List every field in the flowQuote, email, status and notification content, one by one
  2. Judge what happens when the field is wrongCheck whether it affects wording, an amount or an action that cannot be undone
  • A mistake affects only the wording
    Give it to the modelNames, descriptions and summaries come from the model
  • A spec or formula can compute it
    Code computes and overridesAmounts, quantities and specs follow the code result and override model output
  • The action cannot be undone
    Add human approval before executionA person confirms before sending, deleting or charging, and authorization lives in the downstream system

All three paths can appear in the same flow. In one quote, the name takes the first path, the amount takes the second and the sending takes the third.

Failure handling: cooldowns, notify on success only, fallback content

Model calls time out, get rate limited and sometimes return content that fails validation. Without a designed failure path, one failure grows into a chain of failures. These are the general practices.

  • After a failure, enter a cooldown instead of retrying at once, so retries do not pile up into a storm.
  • Send notification emails only after the main flow succeeds, and throttle each recipient, for example one email per 10 minutes.
  • When an API key stops working, abort the whole run instead of calling a dozen times with the same bad key.
  • When a public-facing generation feature fails, return prepared fallback content so the user never sees a blank screen.
  • Add stuck-job detection to background queues and cap the number of restarts.

The diagram below traces the gates a request passes from input to action. Malformed input is returned at once. A request that fails validation cools down and retries; once retries hit the limit, it falls back to prepared content with a log entry, or goes to a person.

Fig. 3The action runs only after every gate passes, and failed requests have exits
  1. Input checkPre-checkBlocks malformed input and content that should not enter
  2. Input rejected: returned at onceRejectedMalformed or out-of-scope content never reaches the model
  3. Model outputGenerateHandles text and creative copy only
  4. Structure and value validationVerifyFormat, source quotes and numbers checked one by one
  5. Validation failed: cool down and retry, fallback after the limitRetry or fallbackRetries are capped; failures are logged or handed to a person
  6. Rule overrideOverrideAmounts and specs follow the code rules
  7. Action runs only on successActSending, writing and notifying happen only here

One request from input to action

A team member kneels and tightens a joint on a blue pipe with a wrench

Quota separation and rate limits: every path that calls the model needs both

The quota given to users must not be consumed by internal batches and tests. Internal bulk processing uses a separate key and user requests use a key of its own, so a usage chart can show anomalies: a sudden spike is an anomaly and is not mixed in with routine batch work.

Every new path that calls the model, such as a report or a follow-up question, gets a quota and a rate limit at the same time. That means an hourly cap per user and a per-minute cap per IP. A path added later sits outside the original protection and has to be checked one by one.

A service that keeps state in memory, such as locks, queues, caches and rate-limit counters, can run as only one process. With several processes or machines, that state diverges and stops working. This is a simplification with a known ceiling, and the development team writes the ceiling and the next step into the handover documents: when traffic grows, move locks, queues and rate limiting into shared storage.

Failures that look like success: no error message, nothing done

The hardest AI automation failures to catch look like success: no error message, the work simply never happens. These silent failures are common across the industry.

  • A parameter never reaches the model call, type checks cannot see it, and output is still produced as usual.
  • A write returns success while no row was actually updated.
  • A scheduler misses a task, with no error, because the task simply never ran.
  • When the connection points to the wrong database, no pending items looks the same as there really being none.
  • A setting is rewritten by code, or an empty string overwrites the default value.

The matching checks follow a fixed pattern. A wiring check compares the parameters actually sent. A read-back after each write confirms the data changed. No data and wrong database are checked separately, starting with the connection target. When configuration is missing, the service refuses to start or raises a clear alert instead of quietly running on defaults.

Continuous monitoring falls under the MEASURE function of the AI RMF from NIST, 2023, which analyzes, assesses, benchmarks and monitors AI risk with quantitative, qualitative or mixed methods. The generative AI companion document, NIST, 2024 (NIST AI 600-1), lists additional risks of generative systems, including information integrity. Each check should fail when the system is broken, which is how a check that ran is told apart from a check that is correct.

Test environment isolation: no email reaches a real person

A test environment should be isolated to the point where it cannot touch real people or production data. These are common measures.

  • A test environment sends only to the operator, or sends nothing and returns a dry-run result, with [Test] added to the subject.
  • When an internal interface has no key, or a key shorter than 32 characters, the whole group returns 404 and looks nonexistent from outside.
  • Responses carry no personal data, and email addresses are looked up on the server only at the moment of sending.
  • The production database is accessed only with read-only tools, and database change scripts are repeatable and registered in advance.

Acceptance: replace model calls with files

To accept an AI workflow, each model call can be saved as a file and answered by a stand-in responder, question by question. The same request always gets the same key, so a rerun does not answer twice. Results before and after a rule change can be compared question by question, and no client quota is consumed. The fixed question set has layers: regression questions with assertions, plus questions written in the voice of real users, whose output text is read directly because a score cannot show whether the text reads smoothly. The stand-in only verifies that the flow and the rules fit together and cannot represent the wording of the production model, so an end-to-end run with the production model still happens on a test machine. For evaluation methods, see how to evaluate an AI Q&A system before launch.

For pre-launch and post-launch checks, the ML Test Score from Breck et al., 2017 is a 28-item checklist covering testing and monitoring requirements both before and after launch. For operations after launch, see after an AI Q&A system goes live, and for costs, see how to estimate the cost of an AI project.

When automation does not fit

  • The action cannot be undone, and the flow has no place for human review.
  • The rules are too numerous to write as code, and every case needs judgment.
  • The volume is so small that handling it by hand costs less.

What to prepare

  • The flow to automate and the actions it triggers.
  • Which fields are decided by rules, and which document or back office holds those rules.
  • Fallback content for failures and the person who takes over by hand.
  • Who can read the logs and how long the logs are kept.
  • The quota and the budget ceiling.

With these in place, the development team can inventory the flow and set the order of the guardrails. When ready, contact the development team to walk through the flow.

(Contact)

Start a project.

Three steps to a clear direction and budget range.

  1. 01Book the first meeting: choose a time. A full specification is not required.
  2. 02A 15 to 30 minute online consultation: direction, budget range, and draft timeline.
  3. 03After materials are reviewed, a quote and delivery specification follows in about 3 to 5 working days.
Email
hello@polish-design.com.tw
Mailing address
3F, No. 191-1, Zhifu Rd., Zhongshan Dist., Taipei 104, Taiwan

Book the first meeting

Monday to Friday, 16:00–18:0030 minutes online

Choose a time, then confirm with a Google account or an email address. A confirmed booking can be added to the calendar.

Choose a time

Or send the details first

Not ready to pick a time yet: leave the project details here and the team replies by email. A meeting can still be booked right after sending.

More details (optional): service, stage, links, source

Information is used only to evaluate this project.

ISO/IEC 27001:2022 certificate

(Certificate)

ISO/IEC 27001:2022

Certification body
ARES International Certification
Scope
The development process for interactive immersive 3D systems, and network and infrastructure operations and management.

Verify with ARES

Urbird

Urban renewal you can see.

Before construction begins, landowners can walk through their new homes. From consent forms to demolition notices, everything runs in one system.

More than 100 modules, AI features included, combined to each developer’s needs.