Coach: cap the plan arrays in the schema, not only in the prompt
create.md asks for "1-7 routines, each 3-12 exercises" and validate.js slices at MAX_ROUTINES / MAX_EX_PER_ROUTINE, but the schema the endpoint decodes against had no bound at all. A model that starts repeating itself never reaches the validator: qwen2.5:3b walks the library id by id, three sets of eight apiece, until it exhausts the 16k output limit — twelve minutes for an answer that arrives truncated, which the adapter turns into "the answer was cut off at the output limit" and a job that would already have hit COACH_JOB_TIMEOUT_MS. maxItems on the two arrays states the caps that already exist, where the decoder can enforce them.
This commit is contained in:
2 files changed
+15
-1
No files matched your search
@@ -72,13 +72,20 @@ export const CREATE_SCHEMA = {
|
||||
summary: STR,
|
||||
basedOn: STR,
|
||||
week: { type: 'object' },
|
||||
// The caps are the validator's own (MAX_ROUTINES, MAX_EX_PER_ROUTINE), stated here as well
|
||||
// because "1-7 routines, each 3-12 exercises" in create.md is only a request. A small model
|
||||
// that starts repeating itself does not stop at a request: qwen2.5:3b walks the library id by
|
||||
// id, three sets of eight apiece, until it hits the output limit — twelve minutes for an
|
||||
// answer that arrives cut in half and cannot be parsed. maxItems ends that run at seven
|
||||
// routines instead.
|
||||
routines: {
|
||||
type: 'array',
|
||||
maxItems: 7,
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: STR, name: STR, emoji: STR, prog: STR, why: STR,
|
||||
ex: { type: 'array', items: EX_SCHEMA }
|
||||
ex: { type: 'array', maxItems: 20, items: EX_SCHEMA }
|
||||
},
|
||||
required: ['id', 'name', 'ex']
|
||||
}
|
||||
|
||||
@@ -68,6 +68,13 @@ test('the create schema requires what the week resolves through: a routine id, a
|
||||
assert.ok(checked.errors.some(e => e.includes('week[1] points at "r1"')));
|
||||
});
|
||||
|
||||
test('the create schema caps the two arrays the validator caps, so a repeating model stops', () => {
|
||||
// validate.js slices at MAX_ROUTINES / MAX_EX_PER_ROUTINE; a model that never stops emitting
|
||||
// otherwise runs to the output limit first and the answer arrives truncated and unparseable.
|
||||
assert.equal(SCHEMAS.create.properties.routines.maxItems, 7);
|
||||
assert.equal(SCHEMAS.create.properties.routines.items.properties.ex.maxItems, 20);
|
||||
});
|
||||
|
||||
test('older sessions in a review window are compacted, the recent ones keep full sets', () => {
|
||||
const many = Array.from({ length: FULL_DETAIL_SESSIONS + 4 }, (_, i) => workout('2026-08-' + String(i + 1).padStart(2, '0')));
|
||||
const p = build(S(many), { handle: 'h1', kind: 'review' });
|
||||
|
||||
Reference in new issue
Block a user