mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-13 22:32:04 +00:00
A Codex backend 400 on the richer Coach tool-call request (and the daily briefing) propagated out of the provider chain runner unwrapped: a 4xx other than 401/403/429 was not classified as a hard provider failure, so it bypassed AllProvidersFailedError and rethrew from the chat route as an HTTP 500. Plain status-card completions, which never send a tools array, were unaffected. Harden the failure path so a provider error can never surface as a 500: - Treat any 4xx a provider wire returns as a hard failure so it cascades and is wrapped in AllProvidersFailedError. InsightSchemaError (the strict-JSON 422 surface) stays the only non-hard class, so that diagnostic is preserved. - The chat route now also classifies a tagged provider error that reaches its catch unwrapped and emits the graceful coach.provider.* SSE frame instead of rethrowing. Only an untagged error keeps the 500 + error-reporter path. Make the Codex 400 diagnosable: fold the redacted upstream response body into the thrown error message and the chain wide-event, so the field the backend rejects is visible in logs (it was previously dropped). Fix the Codex request shape behind the tool-call 400: - Send the required strict flag on each Responses-API function tool. - Replay prior assistant turns as output_text, not input_text, per the Responses API multi-turn contract — the violation only surfaced on round two of the tool loop, which is the path that broke. Codex-only; the OpenAI, Anthropic, local and mock providers are untouched.