Un fallo del Coach dice por qué, sin citar a nadie
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
Reportado así: "Mira mi entrenamiento y dime qué cambiarías" → *The Coach answered with something the app couldn't use*, mientras que "¿Cómo fue mi sesión de Back & Triceps?" funcionaba. El código ya sabía la razón y la tiraba: el parser y el validador devuelven qué campo falló, y `pipeline.js` la descartaba — el registro guardaba sólo la clase de error, así que ni la persona ni el dueño podían distinguir prosa de un JSON cortado a la mitad, de un tipo de cambio que no existe, de un ejercicio que no está en el plan. Ahora `unusable` lleva `detail`: **la queja textual** del parser o del validador, que nombra el campo, más una descripción de la forma de la respuesta —prosa o "empieza como JSON", y cuántos caracteres—. Sin citarla nunca, y eso es deliberado: este renglón va al registro de instancia, que es visible para el admin y abarca a todos los perfiles, y ese registro lleva conteos y resultados, nunca los datos de una persona. Unos pocos caracteres de un plan serían exactamente cómo esa regla se rompe. La longitud más la forma es lo que separa "el modelo ignoró el modo JSON" de "la respuesta se cortó", y no dice nada de nadie. En el prompt de reparación esto es la *segunda* respuesta — la que el modelo manda después de que se le dijo qué estaba mal en la primera —, que es lo más informativo que hay: un modelo que no puede arreglar una queja que acaba de recibir es el problema, no este archivo. Documentado con la tabla de clases de error y qué significa cada una (`docs/AI_COACH.md`), porque el patrón que se reportó se lee solo con ella: el debrief es fácil —todo cadenas y un número— y el review es la tarea más difícil —una lista de cambios tipados, con objetivo, antes/después y un motivo de una tabla fija—. Un modelo que debriefa bien y no puede con el review es un enunciado sobre el modelo. Mutation-check: si el detalle vuelve a estar vacío, el test falla. API 279 en verde.
This commit is contained in:
1 parent
9a4394aff5
commit
91606d9c9e
3 files changed
+71
-3
No files matched your search
@@ -43,9 +43,9 @@ export async function attemptOnce({ adapter, cfg, kind, payload, model, timeoutM
|
||||
}
|
||||
|
||||
const parsed = extractJSON(r.text);
|
||||
if (parsed.error) return { ok: false, repairable: !repair, errors: [parsed.error], raw: r.text, errorClass: 'unusable' };
|
||||
if (parsed.error) return { ok: false, repairable: !repair, errors: [parsed.error], raw: r.text, ...unusable([parsed.error], r.text) };
|
||||
if (!contractOK(parsed.value)) {
|
||||
return { ok: false, repairable: !repair, errors: [`coach_contract must be ${CONTRACT}`], raw: r.text, errorClass: 'unusable' };
|
||||
return { ok: false, repairable: !repair, errors: [`coach_contract must be ${CONTRACT}`], raw: r.text, ...unusable([`coach_contract must be ${CONTRACT}`], r.text) };
|
||||
}
|
||||
|
||||
// Everything above is transport: did the provider answer, is there a JSON object in what it
|
||||
@@ -69,11 +69,41 @@ export async function attemptOnce({ adapter, cfg, kind, payload, model, timeoutM
|
||||
daysPerWeek: payload.coachProfile?.daysPerWeek
|
||||
});
|
||||
|
||||
if (!checked.ok) return { ok: false, repairable: !repair, errors: checked.errors, raw: r.text, errorClass: 'unusable' };
|
||||
if (!checked.ok) return { ok: false, repairable: !repair, errors: checked.errors, raw: r.text, ...unusable(checked.errors, r.text) };
|
||||
if (checked.nochange) return { ok: true, nochange: true, reading: checked.reading };
|
||||
return { ok: true, result: checked.proposal || { bundle: checked.bundle, summary: checked.bundle.summary } };
|
||||
}
|
||||
|
||||
/**
|
||||
* Why an answer was unusable, in a line the admin card can show.
|
||||
*
|
||||
* Without this the log said "the app could not use it" and nobody — not the person who asked, not
|
||||
* the owner who has to fix it — could tell whether the model wrote prose instead of JSON, named a
|
||||
* change type that does not exist, pointed at an exercise that is not in the plan, or answered a
|
||||
* different question entirely.
|
||||
*
|
||||
* What it carries is the *complaint* (from the parser or the validator, which name the field) and a
|
||||
* content-free description of the answer — prose or JSON-ish, and how long. Deliberately not a
|
||||
* quotation: this line goes into the instance log, which is admin-visible and instance-wide, and
|
||||
* that log carries counts and outcomes and never one person's data. A few words of a plan would be
|
||||
* how that rule breaks. The length plus the shape is what separates "the model ignored JSON mode"
|
||||
* from "the answer was cut off mid-object", and it says nothing about anybody.
|
||||
*
|
||||
* On a repair round this is the *second* answer — the one sent after being told what was wrong with
|
||||
* the first — which is the most informative thing there is: a model that cannot fix a complaint it
|
||||
* was just handed is the problem, not this file.
|
||||
*/
|
||||
function unusable(errors, raw) {
|
||||
const text = String(raw || '').trim();
|
||||
const shape = !text ? 'the provider answered with nothing'
|
||||
: /[[{]/.test(text) ? `an answer of ${text.length} characters that starts like JSON`
|
||||
: `prose of ${text.length} characters`;
|
||||
return {
|
||||
errorClass: 'unusable',
|
||||
detail: [...(errors || []).slice(0, 4), shape].filter(Boolean).join(' · ').slice(0, 300)
|
||||
};
|
||||
}
|
||||
|
||||
/** The whole loop: one attempt, then one repair round if the answer was fixable (FR-48). */
|
||||
export async function runPipeline(opts) {
|
||||
let attempt = await attemptOnce(opts, null);
|
||||
|
||||
Reference in new issue
Block a user