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 bound.PromptMaxBytes != 32768 || 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 TestBindCurrentRejectsPromptOverConfiguredByteLimit(t *testing.T) { task, providers := currentFixture(t, "full_ai") task = changeCurrentAgent(t, task, func(agent map[string]any) { agent["prompt"].(map[string]any)["max_bytes"] = 3 }) _, err := Bind(task, providers) if err == nil || !strings.Contains(err.Error(), "prompt") { t.Fatalf("prompt limit was ignored: %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) } }