What kept breaking in my AI counselor. It was never the prompt.

what-kept-breaking-in-my-ai-counselor-it-was-never-the-prompt.

For the last month I’ve been building 予安 (Yu An), an AI counselor inside iYarrow, a small divination site I run alone. She talks with a guest about whatever is weighing on them, and when a reading would help she picks a tradition (I Ching, Zi Wei Dou Shu, tarot, a few others) and the guest draws the cast. She is openly an AI. There’s a daily free allowance, and past it, talking with her costs credits.

Every change to her goes through a written proposal that says what was wrong, usually with numbers from production. That gives me something most side projects don’t have: a record of what kept breaking. I went back through all of it, 25 days and a few dozen changes, expecting to find a lot of prompt fixes.

There were a few. But the bugs that came back, the ones I fixed three or five times, were not prompt bugs. They were places where the architecture let one decision live in two places, or happen in the wrong order. Here are the five patterns, and where each decision lives now.

Where each decision lives in one turn: code decides crisis, billing, opener move and language; the model writes the words

1. Safety was a branch in the paywall chain

If a guest writes that they don’t want to live, she must answer with care and point to a helpline, whatever their balance. That sounds like one rule. It took five fixes, all on the same day, each closing a gap the previous one left:

  1. A text turn ran the credit check before the crisis reply, so a guest with no credit who wrote 「我不想活了」 got an “out of credits” error. Voice calls already skipped the check; text didn’t.
  2. The keyword backstop only knew Traditional Chinese. 「我想自殺」 was caught, 「我想自杀」, the same sentence in Simplified, was refused. And a guest who could pay was charged for the crisis turn.
  3. On a day the house spend cap was hit, every crisis turn got a canned paragraph instead of a real reply.
  4. Fixing that made a new path that was unreachable: a guest with no credit couldn’t even open a sitting on a capped day, so they never got far enough to be in crisis.
  5. The helpline numbers followed the screen language, so a Chinese-speaking guest abroad was told to dial a Taiwanese number.

None of these was a bad prompt. The root cause was structural: safety was one more branch inside the billing flow, so every new billing rule could get in front of it. The fix was to make it a precondition. The crisis check now runs before the guard is ever asked:

if st.Crisis || (!acted && crisisKeyword(content)) {
    // A guest in crisis never meets a paywall, and the house pays for
    // every crisis turn: the guard is not asked.
    in.crisisHouse, in.crisisFixed = true, h.crisisCapped(ctx, uid)
} else if in.dec, err = h.guard.CheckSitting(ctx, uid, st.freePass()); err != nil {
    // ... (one more house-paid branch and paywall bookkeeping elided)
    return chat.GateError(err, h.logger, uid)
}

Once a sitting is flagged, every later turn runs with an empty toolkit. Not a prompt saying “don’t do readings now”, but no tools at all. A prompt is a request; an empty toolkit is a fact.

One gap is still open, and I’d rather say so. A crisis line that contains none of the keywords is only a crisis once the model flags it, and the model only sees the line if the guard lets it through. A guest with nothing left who writes something the keyword list misses still gets the ordinary refusal. The credit dialog in her room carries one helpline line for that case. It’s a mitigation, not a fix.

2. The gate and the meter lived in different places

Every model call costs money and has to be charged to someone: the guest, or the house. The file that decides this is the most-changed file in the project, 33 commits. Most of those commits are the same bug in new clothes:

  • Free regenerations of a chart essay never checked the cap and never recorded the spend.
  • Regenerating an unlocked reading built a billing decision with no price, so it recorded $0.
  • Changing your birth details gave unlimited free rewrites.
  • Unheard call audio and repeated opening lines weren’t counted at all.

The pattern: checking (“may this call happen?”) and recording (“this call cost X”) were two separate steps in two separate places, so any new code path could do one and skip the other. The spend cap’s meaning also changed twice, from “all spend” to “only spend the house pays for”. Credit-paid usage is sold above cost, yet a few paying guests on voice calls could use up the cap and lock everyone out, paying guests included.

What it looks like now: the check returns a decision, and the main recording functions take that decision as an argument, so the price comes from the check rather than from whoever is recording. It isn’t airtight. The $0 bug was a decision built by hand without a price, and there’s still a side door for auxiliary costs that takes no decision at all. But the default path now makes skipping the check awkward instead of easy.

3. State was written before the gate said yes

Three bugs with the same shape:

  • A guest past their daily limit could cast a hexagram. The cast was saved and shown, and then interpreting it failed with a 429. Every one of the 19 unanswered casts in production came right after a guest hit the limit.
  • That refused cast also left behind a conversation thread named after a question nobody answered.
  • If a reply failed and the guest retried, the cards were drawn again. A tarot reading where the cards change on retry isn’t a reading.

Each time, something durable (a cast, a thread, a draw) happened before the step that could refuse it. The fix is ordering: a read-only check before anything is written, and the first draw is pinned in the sitting’s state before the model runs, so a retry replays the same cards.

4. One decision, several detectors

“What language is the guest speaking?” got decided in at least three places: the reply prompt, the greeting and status lines, and the crisis resources. Each had its own heuristic and its own thresholds.

So they disagreed. Replies followed the UI locale instead of what the guest typed, and 153 of 161 questions written in Simplified Chinese got answers in Traditional. Later, inside a single sitting, the greeting could be in one language and the reply in another. The voice gate nearly billed Mandarin text-to-speech for a Vietnamese guest.

The fix was boring and complete: one function decides the reply language from what the guest wrote, and everything in the room calls it. If you find yourself writing a second “detect X” helper with slightly different rules, that’s the bug, before it has a symptom.

5. Rules with a number in them leaked out of the prompt

Some behavior started in the prompt and had to move to code, because the model couldn’t see the state the rule depends on:

  • Openers. Her opening line came from a deterministic rule, and I got the identical sentence two visits in a row. Asking the model to “vary your openers” can’t work, because it has no idea what it said last time. Code now picks one of 22 opening moves by weight, excluding the last two used, and the prompt gets only the chosen move.
  • Follow-ups. She asked about the same unfinished matter every visit. Now a ledger caps it:
// The thread caps. They are product rules, not tuning: reference last time
// once, keep the guest's agenda central, never pursue.
const (
    maxThreadAsks      = 2
    ignoredSkipOpeners = 2
    ignoredCooldown    = 7 * 24 * time.Hour
)
  • Reading style. A prompt rule banning one technical term made her drop it even when it mattered. Production showed 34% of replies still opened with cast metadata, and 15 of 40 follow-up replies re-read the whole cast. The fix there stayed in the prompt, but it came with a script that measures reply health on real traffic, because until then nothing measured any of it.

The test I ended up with: if a rule has a number in it (“at most twice”, “within seven days”, “30 a day”), the prompt can know the rule exists, but code has to hold the count.

The pattern behind the patterns

What broke Symptom Where the decision lives now
Safety inside billing Guest in crisis got “out of credits” Precondition before the guard
Check and record split Calls recorded at $0, or not at all One guard decision, recorded as-is
Write before gate Cast shown, then refused; cards redrawn Read-only check first; draw pinned in state
Many detectors Reply language disagreed with greeting One function, every caller
Counts in the prompt Same opener twice; same question every visit Code picks, ledger counts, prompt writes

Looking at all of it together, the model was rarely the problem. It writes almost everything she says, and it does that well. What broke was everything around it: the order of operations, where a decision was made, and how many places made it. Those are ordinary software bugs, and they recur for the ordinary reason: the architecture allows them.

Not everything that changed was a bug. The “how did it go?” feedback ask was rebuilt three times in three days (a card, then an email, then a line she says in her own words), but that was me not knowing what I wanted, not a structure that made it fail.

Yu An is live at iYarrow, still in beta. If you’re building something conversational and drew these lines somewhere else, I’d like to hear where.

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
firecracker-rate-limiters:-token-buckets-for-network,-disk-and-entropy,-worked-through

Firecracker rate limiters: token buckets for network, disk and entropy, worked through

Related Posts