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

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:
dsantillan committed 2026-09-23 19:27:25 -04:00
1 parent 9a4394aff5
commit 91606d9c9e
3 files changed
+71 -3

No files matched your search

+24
View File
@@ -57,6 +57,30 @@ The health week is deliberately *not* the health file: averages of a metric per
metrics, and never the samples. A week of sleep and resting heart rate is what changes a volume
decision; 288 heart-rate samples are tokens spent to tell the model nothing more.
## When it fails
`api/coach/core/pipeline.js` turns a failed job into one class, and the app turns that class into a
sentence (`frontend/src/lib/coach-api.js`). The classes worth knowing:
| Class | What it means | Fixed by |
| --- | --- | --- |
| `provider` | the request itself failed — a 4xx/5xx, an endpoint that refused the model, or an answer **cut off at the output limit** (the adapter says so in those words) | the provider setup, or a bigger model for the task |
| `unusable` | the model answered, but not the JSON the app needs — **after** the one repair round, which tells it exactly what was wrong | a model that can hold the schema |
| `auth` | the provider rejected the credential | the key |
| `off` | the Coach is off for this instance | the admin card |
A review is the hardest task by a distance: a list of typed changes, each with a target, a
before/after of the right shape and a reason from a fixed table. A debrief is all strings and one
number. So *a model that debriefs fine and cannot review* is a normal thing to see, and it is a
statement about the model rather than about this code.
Which is why an `unusable` failure now **says why** in the admin card's job log
(`lastError.detail`): the parser's or the validator's own complaint, which names the field, plus a
content-free description of the answer — prose or JSON-ish, and how many characters. That is what
separates "the model ignored JSON mode" from "the answer was cut off mid-object"; it is never a
quotation, because the instance log is admin-visible and instance-wide and carries counts and
outcomes rather than the plan it was reading.
## Jev decides, the model writes
Two models with two jobs, and the split is deliberate: **the text model writes the plan** (it is the