修复接续流的增量bug

This commit is contained in:
CJACK
2026-04-06 02:01:41 +08:00
parent a608a4bd95
commit 4d36afea4c
9 changed files with 140 additions and 21 deletions

22
internal/sse/dedupe.go Normal file
View File

@@ -0,0 +1,22 @@
package sse
import "strings"
// TrimContinuationOverlap removes the already-seen prefix when DeepSeek
// continue rounds resend the full fragment snapshot instead of only the new
// suffix. Non-overlapping chunks are returned unchanged.
func TrimContinuationOverlap(existing, incoming string) string {
if incoming == "" {
return ""
}
if existing == "" {
return incoming
}
if strings.HasPrefix(incoming, existing) {
return incoming[len(existing):]
}
if strings.HasPrefix(existing, incoming) {
return ""
}
return incoming
}