The JSON was always valid and it prescribed 31 chest sets a week: numeric constraints get calculated in code, before the prompt
An AI workout generator returned perfectly valid JSON and prescribed 31 chest sets a week: numeric constraints get calculated in code, before the prompt.

Luca Di Domenico
· 2 min read
In short
A workout generator built with AI always returned valid JSON, and it prescribed 31 chest sets a week to someone who only wanted to stay in shape, and 3 sets of 5 on the leg press to a beginner who had flagged a knee problem. The fix was taking the numbers out of the prompt: an ordinary function calculates the limits before the call — 10-12 weekly sets per muscle for a beginner, 12-16 for an intermediate, 14-20 for an advanced lifter, longer rest periods if the goal is strength, a deload week every six — and the model is left with the choice of exercises inside those boundaries. Valid JSON only tells you the response has the right shape, without telling you that what’s inside makes sense.
🏋️ A workout generator built with AI always returned perfectly valid JSON. Too bad it prescribed 31 chest sets a week to someone who only wanted to stay in shape.
Valid schema, dangerous advice
And to a beginner who had flagged a knee problem, 3 sets of 5 on the leg press.
Technically it was all correct: valid schema, right fields, structure respected.
The advice, though, was wrong, and in some cases it could even be dangerous.
The numbers leave the prompt and move into the code
So whoever built that coach changed the way they use the model: the AI doesn’t decide the numbers anymore.
Before the prompt is built, an ordinary function calculates the training prescription using goal, experience, available days and health information.
Only then does the model come in.
It receives limits that are already set, and it can choose the exercises without stepping outside those boundaries.
Which limits the function calculates
For example:
- 10-12 weekly sets per muscle for a beginner
- 12-16 for an intermediate
- 14-20 for an advanced lifter
- longer rest periods if the goal is strength, shorter ones for metabolic work
- a deload week every six weeks, or every four when there’s a medical flag
The weekly volume ranges have backing in the literature: the dose-response meta-analysis by Schoenfeld, Ogborn and Krieger (Journal of Sports Sciences, 2017) associates each additional weekly set with an average 0.37% increase in muscle gain, and analyses the bands under 5, 5-9 and 10 or more weekly sets per muscle separately. On rest periods, the American College of Sports Medicine position stand (2009) recommends 2-3 minutes with heavy loads and 1-2 minutes for hypertrophy work.
The number of available days affects volume too, but always within defined rules.
From five days up, the weekly limit rises by two sets, up to a maximum. Below two days it drops, but never under six sets.
Why the same reasoning applies to other AI products
The interesting part, to me, is that this reasoning applies to a huge number of AI products.
There are decisions you can leave to the model.
And there are others that, when they go wrong, can cost you money, create security problems or do real damage.
Those are better taken out of the prompt and moved into the code.
It’s the same separation I apply in projects that deliver custom-built software for companies: the rules that always have to hold live in the code, and the model is left with the flexible part.
Four rules for splitting code and prompt
In practice:
1) Decide up front what the AI gets to choose and what has to be fixed.
2) Anything that has to follow precise rules, you calculate with ordinary code.
3) You leave the model the more flexible part.
Here it can choose the exercises, but it can’t make up sets, rest periods and loads.
4) And above all: valid JSON only tells you the response has the right shape.
It doesn’t tell you that what’s inside makes sense.
Which decisions are you still leaving to the model that, if they go wrong, could really cost you?
Sources
- Dose-response relationship between weekly resistance training volume and increases in muscle mass — Schoenfeld, Ogborn, Krieger (Journal of Sports Sciences) — 2017 meta-analysis of 34 treatment groups drawn from 15 studies, published in Journal of Sports Sciences 35(11):1073-1082: each additional weekly set is worth an average 0.37% increase in muscle gain, and the bands under 5, 5-9 and 10 or more weekly sets per muscle are analysed separately. It places the 10-weekly-sets-per-muscle threshold in the literature
- The Resistance Training Dose-Response: Meta-Regressions Exploring the Effects of Weekly Volume and Frequency on Muscle Hypertrophy and Strength Gain — Pelland et al. (SportRxiv) — Meta-regression across 67 studies and 2,058 participants, preprint posted 4 October 2024 and later published in Sports Medicine in 2025: raising weekly volume improves both hypertrophy and strength at 100% posterior probability, but with diminishing returns, more pronounced for strength than for hypertrophy
- ACSM Position Stand: Progression Models in Resistance Training for Healthy Adults — American College of Sports Medicine position stand, Medicine & Science in Sports & Exercise, March 2009, 41(3):687-708: it separates novice, intermediate and advanced trainees and recommends 2-3 minute rest periods with heavy loads on core exercises, up to 3-5 minutes for 1-6 RM strength work, against 1-2 minutes for hypertrophy work
Want to know what this means for your product?
If you're building software with AI and want a second opinion on how you're working, tell me about your project.
Related articles
Keep reading
409,000 human decisions on an AI agent’s commands: one threat out of three gets through, and confirmation fatigue is to blame
Read: confirmation fatigue