Coach: the create schema requires a routine id and a week

CREATE_SCHEMA is handed to OpenAI-compatible endpoints as a grammar to decode against, and it
left both `routines[].id` and `week` optional. Small local models take that offer: llama3.2:3b
and qwen2.5:3b both answer with routines that carry no id, and a week naming what they wrote
into `name` instead. Nothing in the week then resolves, validate.js reports "the week schedules
0 days but 3 were asked for", the repair round produces the same answer again, and the job ends
as `unusable` — "The Coach answered with something the app couldn't use."

Requiring the two fields the week resolves through is enough. With them in the schema,
llama3.2:3b produces a plan that passes validatePlan on the first attempt, against the payload
that failed twice before. The validator is untouched; this only stops the grammar from offering
an answer it can never accept.
This commit is contained in:
Konstantinos Thermos committed 2026-09-04 18:46:39 +03:00
1 parent dca6bcdf2d
commit dafc80f1d6
2 files changed
+27 -2

No files matched your search

+7 -2
View File
@@ -59,6 +59,11 @@ const EX_SCHEMA = {
required: ['id', 'sets']
};
// `week` and `routines[].id` are required, not optional: the week is the only thing that says
// which day trains which routine, and it points at a routine by id. A schema that leaves either
// out lets a small local model answer with routines that have no id and a week naming "r1" —
// grammar-valid, and something validate.js can only ever reject ("the week schedules 0 days but
// 3 were asked for"), through the repair round and out as a failed job.
export const CREATE_SCHEMA = {
type: 'object',
properties: {
@@ -75,7 +80,7 @@ export const CREATE_SCHEMA = {
id: STR, name: STR, emoji: STR, prog: STR, why: STR,
ex: { type: 'array', items: EX_SCHEMA }
},
required: ['name', 'ex']
required: ['id', 'name', 'ex']
}
},
customEx: {
@@ -83,7 +88,7 @@ export const CREATE_SCHEMA = {
items: { type: 'object', properties: { id: STR, n: STR, bp: STR, desc: STR }, required: ['id', 'n'] }
}
},
required: ['coach_contract', 'routines']
required: ['coach_contract', 'week', 'routines']
};
export const DEBRIEF_SCHEMA = {