fix(streaming): drop Anthropic ping keepalives before OpenAI conversion

Upstream Anthropic keepalive frames (event: ping) leaked into OpenAI
Chat Completions SSE streams, crashing strict clients (Cursor, Hermes,
OpenAI SDKs) on unexpected event types. Error events still forward.

Fixes #5203
This commit is contained in:
MHJoy99
2026-09-13 13:30:50 +06:00
committed by mhjoy
parent bdb42e22f8
commit 7511e4de59
@@ -418,6 +418,15 @@ func (s *GatewayService) handleCCStreamingFromAnthropic(
}
processAnthropicEvent := func(event *apicompat.AnthropicStreamEvent) bool {
if event == nil {
return false
}
// Drop Anthropic keepalive pings before OpenAI conversion:
// leaking `event: ping` frames crashes OpenAI-stream clients.
// Error events must still forward — they carry upstream failures.
if event.Type == "ping" {
return false
}
if firstChunk {
firstChunk = false
ms := int(time.Since(startTime).Milliseconds())