Stop repeating streamed Claude text when assistant blocks arrive split
Claude Code emits one assistant event per content block, so a text block that streamed at index 1 after a redacted (empty) thinking block arrives alone at index 0 of its event. The translator aligned completed blocks by that local index and cleared stream state after every event, found no streamed text, and re-emitted the whole paragraph as a new text part. Claim the streamed block of the same kind whose text prefixes the completed one, and keep stream state for the whole message (reset on message_start or a new message id).
This commit is contained in:
@@ -352,9 +352,7 @@ func (s *session) processExit(p *process, err error) {
|
||||
turn := s.turnID
|
||||
s.running = false
|
||||
s.turnID = ""
|
||||
s.streamBlocks = map[int]blockState{}
|
||||
s.streamText = map[int]string{}
|
||||
s.streamOrdinals = map[string]int{}
|
||||
s.resetStreamLocked()
|
||||
s.mu.Unlock()
|
||||
if !running {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user