Notes ·

How to make an AI follow hard rules: let code check the numbers

Short answerLet the model read and extract, but let code enforce. Turn what the customer said into structured conditions, check every record against them in plain code, let the model compare only what passed, allow it to return fewer results, and refuse to answer from incomplete input.

We build search for an employment agency: families describe the domestic helper they need, and staff need a shortlist from a few hundred live profiles. One afternoon a family asked, in several messages, for someone under 33, taller than 150 cm and under 55 kg. The search recommended a 44-year-old and a 39-year-old.

Nothing crashed. The system did exactly what it was built to do. That was the problem.

What went wrong

  • A stale summary. The search used a summary of the conversation made three minutes earlier. The family's nine messages with the actual requirements were not in it.
  • A cached result. When the family replied "I need younger", the next search returned the same cached answer.
  • Rules as suggestions. Age was a small penalty in a ranking score, not a condition. The final choice was left to the model, which had been told to return exactly three people.

There were quieter bugs too. "Filipino or Myanmar" had been excluding Myanmar candidates, because the text "Filipino or" contains "no ". And "below 55kg, above 150cm" was once read as an age range of 15 to 55.

The design that fixed it

  1. Read everything, every time. Each search reads the whole conversation as it is now. No summaries, no cached results.
  2. Extract into structure. One model call turns the conversation into a list of conditions, each marked must-have or preference, with the customer's own boundary kept: "under 33" excludes 33, "33 and below" includes it.
  3. Enforce in code. Plain, unit-tested code checks every record against every must-have. A profile that explicitly says "not willing to care for dogs" does not appear for a family with a dog. Missing information becomes "confirm at interview", not a silent pass.
  4. Let the model compare only what passed. It reads real work histories and writes the note. It is asked for at most three people, and may return fewer, or none.
  5. Refuse incomplete input. If the conversation cannot be read in full, or the extraction fails, the search does not run. Staff see why.
  6. Test against real cases. More than 60 real past requests, including this one, are replayed on a staging copy before any change goes live.

The result: about five seconds per search, under one US cent, and a family that says "under 33" gets nobody over 33.

The subtle part: code that overrules the model

Once code is checking the model's work, it is tempting to let code "correct" the model too. We did, and it backfired: a customer said "below 30", then later "age is just a preference, older is fine", and our correction turned the preference back into a hard rule. The rule we now follow: code may override the model's reading only when nothing said afterwards could have changed it. If in doubt, trust the reading and show staff what was understood.

A checklist for any AI that must follow rules

  • Which decisions are numbers or yes/no? Those belong in code.
  • Is the model ever asked for an exact number of results? Change it to "at most".
  • Is anything cached between the customer's words and the answer? Remove it, or prove it cannot go stale.
  • What happens when the input is incomplete? The right answer is usually "stop and say so".
  • Is every past failure now a test case?

Quick answers

How do you stop an AI from ignoring a customer's requirements?

Do not ask the model to enforce them. Have the model extract the requirements into structured conditions, check every record against those conditions in plain code, and let the model choose only among records that passed.

Should an AI search always return a fixed number of results?

No. Asking for exactly three makes the model pad the list with people who do not fit. Ask for at most three, and allow none.

Why should AI systems avoid caching summaries of conversations?

Because the customer may have said something important after the summary was made. Our worst search mistake came from a summary that was three minutes old.

Start a conversation

Tell us about your business.

What you do, how customers reach you, and one thing that takes your team too long. A few lines is plenty. A person reads every email.

Email dylan@silinkai.com
Where
170 Upper Bukit Timah Road, #B1-23, Bukit Timah Shopping Centre, Singapore 588179