feat(kiro): add multi-endpoint fallback & thinking mode support

This commit is contained in:
Ravens2121
2025-12-12 13:43:36 +08:00
parent 204bba9dea
commit 84920cb670
7 changed files with 787 additions and 90 deletions

View File

@@ -3,6 +3,8 @@ package amp
import (
"bytes"
"compress/gzip"
"context"
"errors"
"fmt"
"io"
"net/http"
@@ -148,7 +150,13 @@ func createReverseProxy(upstreamURL string, secretSource SecretSource) (*httputi
// Error handler for proxy failures
proxy.ErrorHandler = func(rw http.ResponseWriter, req *http.Request, err error) {
log.Errorf("amp upstream proxy error for %s %s: %v", req.Method, req.URL.Path, err)
// Check if this is a client-side cancellation (normal behavior)
// Don't log as error for context canceled - it's usually client closing connection
if errors.Is(err, context.Canceled) {
log.Debugf("amp upstream proxy: client canceled request for %s %s", req.Method, req.URL.Path)
} else {
log.Errorf("amp upstream proxy error for %s %s: %v", req.Method, req.URL.Path, err)
}
rw.Header().Set("Content-Type", "application/json")
rw.WriteHeader(http.StatusBadGateway)
_, _ = rw.Write([]byte(`{"error":"amp_upstream_proxy_error","message":"Failed to reach Amp upstream"}`))