A lead should exist only if the customer said yes
- 1
Problem
The AI employee collects a customer's name and phone to create a sales lead. Left to the model, a lead could be created from a misread 'yes', a half-finished conversation — or twice, when a background job retries.
- 2
Investigation
Three distinct failure modes: the model deciding consent, details changing between collection and confirmation, and at-least-once job delivery creating duplicates.
- 3
Approach
Move every consequential decision out of the model. Validate fields in code, read them back with a fixed template in the agent's dialect, store a draft on the conversation, and classify the next message deterministically.
- 4
Solution
Guards classify the reply as yes / no / unclear. Only yes runs create_lead — without the model deciding. The draft id becomes the lead id, so a retried job finds the lead already exists. The model still writes the summary; code decides whether there is anything to summarise.
Lessons learnedLet the model write; let code decide anything with consequences. Idempotency keys are cheaper than apologies.
Source: Wakeel · docs/ARCHITECTURE.md §2