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…
For the past month, I have been constructing 予安 (Yu An), an AI counselor embedded within iYarrow, a solitary divination platform I manage. She engages in dialogue with visitors about their concerns, and upon detecting a need for a reading, she selects an appropriate tradition and facilitates the user's participation. She openly identifies as an AI, and access is granted on a daily free basis, with premium conversations costing credits.
All modifications to her system necessitate a written proposal detailing the issue, usually accompanied by production data. This archive provides a comprehensive record of the issues that affected her.
After reviewing the 25 days of development and several dozen revisions, I anticipated finding numerous prompt adjustments. However, I discovered that the majority of the bugs were not prompt-related. Instead, they stemmed from architectural flaws in the system. Here are the five recurring patterns observed, along with the locations where each decision was corrected:
1. Safety was integrated into the paywall chain. When a guest expressed a desire not to live, she was required to respond with compassion and provide a helpline, regardless of their balance. Initially, this appeared as a single rule, but it necessitated five fixes on the same day, each addressing a new gap left by the previous one.
The issues included a text turn executing the credit check before the crisis response, skipping crisis checks for voice calls, a lack of Traditional Chinese keyword backstop, a paid crisis turn for guests with sufficient funds, and incorrect helpline numbers for non-Chinese speakers. The root cause was the safety measure being an additional branch within the billing flow, which made it vulnerable to interference from other billing rules.
The solution involved making safety a precondition, ensuring it ran before any other checks. The crisis check is now executed prior to the guard's assessment, preventing guests in crisis from encountering paywalls and ensuring the house covers all crisis turns.
2. The gate (pricing decision) and the meter (credit tracking) were implemented as separate components, leading to inconsistencies. Each model call incurred costs, which needed to be charged to either the guest or the house. The file responsible for determining this charge ranked among the most altered in the project, with 33 commits.
Many of these commits addressed the same issue: free regenerations of a chart did not consider the cap and failed to record the expenditure. Generating an unlocked reading created billing decisions without pricing, resulting in a recorded value of $0. Similarly, certain interactions, such as changing birth details or repeated opening lines, were not factored into the credit calculation.
The pattern observed was that checking (determining if a call should occur) and recording (recording the associated cost) were performed as two distinct steps in two separate locations, causing inconsistencies when new code paths were introduced. The revised approach: the check now returns a decision, and the main recording functions accept this decision as an argument, eliminating the need for separate charging mechanisms.
While this solution does not completely eliminate the possibility of $0 bugs or side doors for auxiliary costs, it does make bypassing the check more challenging.
3. State was written to the system before the gate permitted it. Several bugs exhibited a similar pattern: guests exceeding their daily limits were still able to cast hexagrams, which were then saved and displayed. However, attempting to interpret these casts would result in a 429 error. Each of the 19 unanswered casts in production occurred immediately after a guest reached their limit.
These unfulfilled casts also left behind incomplete conversation threads, named after unanswered questions. If a guest attempted to retry, the cards would be drawn anew, creating an inconsistent experience. The fix involved reordering the process: a read-only check should be performed before any state is written, and the initial draw should be stored in the sitting's state before executing the model, ensuring that a retry replays the same cards.
4. Multiple detectors identified the same decision using different methods. The phrase "What language is the guest speaking?" was resolved in at least three distinct locations: the reply prompt, the greeting and status lines, and the crisis resources. Each detector had its own heuristic and threshold, leading to inconsistent results.
Replies were sometimes determined by the UI locale rather than the guest's input, resulting in 153 out of 161 Simplified Chinese questions being answered in Traditional Chinese. This inconsistency arose because each detector employed different methods and criteria for determining the guest's language, leading to disagreements in the system's responses.
The remedy was to consolidate these detectors into a single, unified approach, ensuring consistent language identification across all system components.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to