fix: chat stream closes when stripMarkers produces empty output
When a streaming chunk contains only markers/fences, stripMarkers returns empty bytes. The 9P server interprets a zero-length Rread as EOF, closing the client's FD. Fix: loop in streamAgentChatText, advancing the offset past marker-only chunks until real content arrives.
This commit is contained in:
parent
61dbf760ac
commit
d861e41d31
|
|
@ -125,11 +125,18 @@ func streamAgentChat(ctx HandlerCtx, cctx context.Context, base string) ([]byte,
|
|||
func streamAgentChatText(ctx HandlerCtx, cctx context.Context, base string) ([]byte, string, error) {
|
||||
merged, cancel := mergeCtx(ctx, cctx)
|
||||
defer cancel()
|
||||
data, nextBase, err := streamChat(ctx.AgentLog, merged, base)
|
||||
if err != nil || len(data) == 0 {
|
||||
return data, nextBase, err
|
||||
for {
|
||||
data, nextBase, err := streamChat(ctx.AgentLog, merged, base)
|
||||
if err != nil || len(data) == 0 {
|
||||
return data, nextBase, err
|
||||
}
|
||||
stripped := stripMarkers(data)
|
||||
if len(stripped) > 0 {
|
||||
return stripped, nextBase, nil
|
||||
}
|
||||
// All data was markers/fences — advance base and wait for more.
|
||||
base = nextBase
|
||||
}
|
||||
return stripMarkers(data), nextBase, nil
|
||||
}
|
||||
|
||||
// stripMarkers removes [[[...]]] marker lines and source fence lines from raw
|
||||
|
|
|
|||
Loading…
Reference in New Issue