diff --git a/internal/gateway/gateway.go b/internal/gateway/gateway.go index 08e1bb7..67c58c8 100644 --- a/internal/gateway/gateway.go +++ b/internal/gateway/gateway.go @@ -401,6 +401,7 @@ func (g *Gateway) prepareRouteBodies(from wire.Protocol, route models.Route, inp // preferred tier. Do not reject a request before the preferred // upstream has even been tried; that tier is attempted only if // the request actually falls back. + g.logger.Debug("skipping fallback tier with incompatible request shape", "component", "conversion", "event", "fallback_tier_skipped", "model", jsonutil.StringAt(input, "model"), "tier", tier, "protocol", protocol, "error", err) continue } return nil, fmt.Errorf("prepare %s upstream request: %w", tier, err) diff --git a/internal/gateway/upstream.go b/internal/gateway/upstream.go index defbf51..b9d272f 100644 --- a/internal/gateway/upstream.go +++ b/internal/gateway/upstream.go @@ -74,6 +74,16 @@ func (g *Gateway) doUpstream(ctx context.Context, route models.Route, bodies map // Restore the body so downstream error handling still sees the original // payload when no retry happens below. resp.Body = io.NopCloser(bytes.NewReader(errBody)) + // Log a capped snippet of the upstream error body so the 400 class is + // visible without dumping full payloads. Bodies stay out of attempt + // records; the hub redactor scrubs configured secrets from log output. + if len(errBody) > 0 { + snippet := string(errBody) + if len(snippet) > 240 { + snippet = snippet[:240] + } + g.logger.Info("upstream error returned or retried", "component", "upstream", "event", "upstream_error_body", "request_id", ids.Request, "model", route.ID, "status", resp.StatusCode, "snippet", snippet) + } if !isStaleReasoningReference(errBody) { return resp, effectiveRoute, nil }