fix(llm): strip inline <think> reasoning from Dahl/MiniMax streams; dedupe identical parallel tool calls; hermetic config tests

This commit is contained in:
OpenClaw Dev 2026-10-25 06:51:20 +01:00
parent 46d98502dd
commit 546a9315d5
6 changed files with 264 additions and 5 deletions

View file

@ -131,6 +131,7 @@ type partialCall struct {
func parseStream(r io.Reader, onDelta DeltaFunc) (Response, error) {
var out Response
var text strings.Builder
var tf thinkFilter
calls := map[int]*partialCall{}
sc := bufio.NewScanner(r)
sc.Buffer(make([]byte, 64*1024), 4<<20)
@ -152,9 +153,11 @@ func parseStream(r io.Reader, onDelta DeltaFunc) (Response, error) {
}
for _, c := range ch.Choices {
if c.Delta.Content != "" {
text.WriteString(c.Delta.Content)
if onDelta != nil {
onDelta(c.Delta.Content)
if v := tf.push(c.Delta.Content); v != "" {
text.WriteString(v)
if onDelta != nil {
onDelta(v)
}
}
}
for i, tc := range c.Delta.ToolCalls {
@ -183,6 +186,12 @@ func parseStream(r io.Reader, onDelta DeltaFunc) (Response, error) {
if err := sc.Err(); err != nil {
return out, fmt.Errorf("read stream: %w", err)
}
if v := tf.finish(); v != "" {
text.WriteString(v)
if onDelta != nil {
onDelta(v)
}
}
out.Content = text.String()
idxs := make([]int, 0, len(calls))
for i := range calls {