Designing AI features with deterministic business rules

How to combine LLMs and automation with clear business logic so outcomes are predictable and auditable.

AI features that matter in production are rarely “pure” ML. They’re hybrids: models or LLMs handle the fuzzy part, and deterministic rules handle guardrails, validation, and business logic. Getting that split right is what makes a feature reliable enough for operators and auditors to trust.

Why mix deterministic logic with AI?

LLMs and other models are great at interpretation and generation. They’re bad at guarantees. If your feature must never suggest a discount above 30%, or must always require a human sign-off when confidence is low, that has to be enforced in code—not in a prompt. Deterministic rules give you predictable behavior at the boundaries: what happens when the model fails, when input is malformed, or when the business says “never do X.”

Patterns that work

Pre- and post-checks. Validate input before it hits the model (format, length, PII stripping). Validate output after (allowed values, safety filters, fallbacks). The model sits in the middle; the pipeline is under your control.

Structured outputs + schema. Where possible, force the model to return JSON that matches a schema. Parse it, validate it, and only then pass it to the rest of your system. If parsing or validation fails, you have a clear failure mode—retry, fallback, or human escalation—instead of silent misuse.

Confidence and thresholds. Use scores or confidence when the model provides them. Define thresholds in config or code: above X you auto-apply, below X you flag for review or skip. That keeps high-impact decisions auditable and consistent.

What I’ve seen in practice

At HubSpot, call summarization and lead enrichment had to work at scale for sales and RevOps. The useful pattern was: LLM or model does the heavy lifting, then a thin layer of business rules decides what gets stored, what gets shown, and what gets queued for review. That kept behavior predictable and made it possible to tune and debug without retraining.

If you’re building AI features that need to be reliable and auditable, start with the rules: what must always be true, what must never happen, and what should trigger a human or fallback. Then plug the model in between. For more on how I approach this kind of work, see AI features and automation and the HubSpot case study.