Files
go-sip/internal/ai/controls_test.go
T

44 lines
1.4 KiB
Go

package ai
import (
"strings"
"testing"
"time"
)
func TestBindCurrentPreservesPromptAndConversationControls(t *testing.T) {
task, providers := currentFixture(t, "full_ai")
bound, err := Bind(task, providers)
if err != nil {
t.Fatal(err)
}
if len(bound.AllowedVariables) != 0 {
t.Fatal("approved prompt controls not preserved")
}
c := bound.Conversation
if c.AllowInterrupt == nil || *c.AllowInterrupt || c.SilenceTimeout != 3*time.Second || c.MaxDuration != 2*time.Minute || c.MaxTurns != 20 || c.SentenceMaxChars != 80 || c.MaxPendingAudioChunks != 32 {
t.Fatalf("approved conversation controls lost: %+v", c)
}
}
func TestBindDoesNotLimitPromptBytes(t *testing.T) {
task, providers := currentFixture(t, "full_ai")
text := strings.Repeat("长", 40000)
task = changeCurrentAgent(t, task, func(agent map[string]any) { agent["prompt"].(map[string]any)["text"] = text })
bound, err := Bind(task, providers)
if err != nil || bound.Prompt != text {
t.Fatalf("prompt was limited or changed: %v", err)
}
}
func TestBindCurrentRejectsUnsupportedBargeInBeforeCall(t *testing.T) {
task, providers := currentFixture(t, "full_ai")
task = changeCurrentAgent(t, task, func(agent map[string]any) {
agent["conversation"].(map[string]any)["allow_interrupt"] = true
})
_, err := Bind(task, providers)
if err == nil || !strings.Contains(err.Error(), "interrupt") {
t.Fatalf("unsupported interruption cannot silently become false: %v", err)
}
}