Here's what each trace teaches you.
**Trace 1 β TypeError: Cannot read properties of undefined.** Real cause: the code trusted the response shape without checking `res.ok` first. Real fix: throw on `!res.ok` with a structured error, then validate the success shape with Zod. The band-aid to reject: `return (body?.elements ?? [])` β this makes the crash disappear and installs silent error-swallowing in its place.
**Trace 2 β 400: messages.1.content: Input should be a valid list.** Real cause: an assistant tool-use turn was replayed as a bare string. Real fix: store and replay `response.content` verbatim; type the history structure so this can't happen silently again.
**Trace 3 β relation does not exist (works locally, fails in staging).** Real cause: the migration was never applied to staging. Real fix: migration lives in the repo; CI checks that migration history matches the target project.
**Trace 4 β 429 contention across accounts.** Covered in depth in the example above. Retrying harder cannot fix contention between requests.
**Trace 5 β eval suite catches numeric mismatches after `.slice(0, 50)` is added.** Real cause: the 'performance cap' silently changed semantics β the model summarised a sample while the report quoted totals. Real fix: compute totals in code over all rows; pass computed aggregates to the model. If context length forces truncation, truncate detail rows β never numbers.