diff --git a/internal/gateway/gateway.go b/internal/gateway/gateway.go index 22291d1..08e1bb7 100644 --- a/internal/gateway/gateway.go +++ b/internal/gateway/gateway.go @@ -230,7 +230,7 @@ func (g *Gateway) handleInference(external wire.Protocol) http.HandlerFunc { if upstreamRoute.Anonymous || (meta != nil && meta.Shaped) { // Key-tier shaped requests were force-streamed like the // anonymous lane; collapse the same way. - // The anonymous lane is served streaming (see forceStreamBody); + // The anonymous lane is served streaming (see prepareAnonymousBody); // collapse the events back into the single document this // non-streaming client asked for. collapsed, err := wire.CollapseStream(bytes.NewReader(responseBody), upstreamRoute.Protocol, model) diff --git a/internal/gateway/upstream.go b/internal/gateway/upstream.go index e2ba172..9c478f5 100644 --- a/internal/gateway/upstream.go +++ b/internal/gateway/upstream.go @@ -469,24 +469,6 @@ func anonymousTool(protocol wire.Protocol, name string) map[string]any { } } -// forceStreamBody returns a copy of body with streaming enabled. Bodies -// that already stream (or are not JSON objects) are returned unchanged. -func forceStreamBody(body []byte) []byte { - var payload map[string]any - if err := json.Unmarshal(body, &payload); err != nil { - return body - } - if streaming, ok := payload["stream"].(bool); ok && streaming { - return body - } - payload["stream"] = true - encoded, err := json.Marshal(payload) - if err != nil { - return body - } - return encoded -} - // requestBodyDumpLimit caps how much of an outbound body is written to the log. const requestBodyDumpLimit = 64 << 10 diff --git a/internal/protocol/stream.go b/internal/protocol/stream.go index 66bc6d1..e25b0bf 100644 --- a/internal/protocol/stream.go +++ b/internal/protocol/stream.go @@ -41,15 +41,6 @@ type bridgeStreamEvent struct { Usage *Usage } -func transcodeStream(w http.ResponseWriter, reader io.Reader, from, to Protocol, model string) error { - _, _, err := transcodeStreamWithUsage(w, reader, from, to, model) - return err -} - -func transcodeStreamWithUsage(w http.ResponseWriter, reader io.Reader, from, to Protocol, model string) (Usage, bool, error) { - return TranscodeStream(context.Background(), w, reader, from, to, model) -} - // TranscodeStream is the request-aware form used by the // gateway. A cancelled client must not receive a synthetic upstream error // after its connection has gone away. @@ -158,10 +149,6 @@ func (writer *sseFlushWriter) Write(data []byte) (int, error) { return n, err } -func forwardSSEWithUsage(w http.ResponseWriter, reader io.Reader, protocol Protocol, model string) (Usage, bool, error) { - return ForwardStream(context.Background(), w, reader, protocol, model) -} - func ForwardStream(ctx context.Context, w http.ResponseWriter, reader io.Reader, protocol Protocol, model string) (Usage, bool, error) { flusher, ok := w.(http.Flusher) if !ok {