Product Engineering
How I Think About Pulling AI Into Real Products
What I learned adding an AI trainer to Virtual Trainer: what the model does, what stays in plain code, and how I test it.
- AI
- Product
- Guardrails
Virtual Trainer has an AI trainer. You can ask it about your progress or your plan, and it answers from your own workout history instead of with generic fitness advice. These are the rules I ended up following while building it.
What the model does
Language models are good at explaining, summarizing, drafting, and answering questions about data you give them. They're bad at anything that has to come out exactly the same every time, like transactions, strict business rules and calculations.
So in Virtual Trainer, workout history, timers, completed sets, account state and progression are all plain code. The AI trainer reads that data and explains it. When it wants to change something, it goes through the app like everything else.
Context
Without context, a model gives the answer it would give anyone. The trainer is useful because it answers from the member's own training data, and most of the work was deciding what goes into that context for each question: what's relevant, what's out of date, and what's too sensitive to send at all. More data didn't always give a better answer.
Rules stay in code
If the trainer suggests a change, like swapping the bench press for dumbbells, the change goes through the same checks as one made by hand before it touches real data.
Progression is where this matters most. Automatic progression in Virtual Trainer has limits, so it can adapt without suggesting unsafe jumps. The trainer doesn't get a second progression system of its own. It can explain what the rules decided and help someone pick between options that are already safe.
Where answers come from
People believe an answer more when they can see what it's based on. "Based on your last four workouts" is easier to trust than advice with no source. When the trainer isn't sure, it should say so, and when it can't answer safely, it should say that instead of guessing.
There should also be a way around it: look at the data yourself, edit what it generated, or ignore the suggestion. I'd rather a generated plan get reviewed before it's applied than have it quietly change someone's account.
Testing it
A good demo doesn't tell you much. I keep a set of real examples: normal questions, edge cases, things it should refuse, and answers that came out wrong before. They get run again whenever the prompt, the context or the model changes.
Besides reading the text, I check whether the answer helped, whether it stayed inside the app's rules, and whether the UI made a failure obvious.