package orchestrator
import (
"strings"
"testing"
"github.com/muyue/muyue/internal/config"
)
func testConfig() *config.MuyueConfig {
cfg := config.Default()
cfg.AI.Providers[0].Active = true
cfg.AI.Providers[0].APIKey = "test-api-key-12345"
return cfg
}
func TestCleanAIResponse(t *testing.T) {
tests := []struct {
name string
input string
expected string
}{
{
"removes standard think tags",
"reasoningresponse",
"response",
},
{
"removes think with attrs",
"reasoningreasoning>\nvisible",
"text\nvisible",
},
{
"removes triple markers",
"text\n<<<\ninternal\n>>>\nvisible",
"text\nvisible",
},
{
"plain text unchanged",
"Hello world",
"Hello world",
},
{
"empty input",
"",
"",
},
{
"removes valid think block",
" on opening tag, so won't match regex
if result3 != ", so won't match
if result4 != "reasoning after it, so won't match
if result_real != "prefix maxHistorySize {
orch.history = orch.history[len(orch.history)-maxHistorySize:]
}
orch.histMu.Unlock()
}
h := orch.History()
if len(h) > maxHistorySize {
t.Errorf("History should be capped at %d, got %d", maxHistorySize, len(h))
}
}