返回 DeepSeek-Reasonix
history_host_recovery_test.go
根目录 / desktop / history_host_recovery_test.go
1 package main
2
3 import (
4 "strings"
5 "testing"
6
7 "reasonix/internal/agent"
8 "reasonix/internal/provider"
9 )
10
11 func TestHistoryMessagesHideHostRecoverySteer(t *testing.T) {
12 userPrompt := "请继续完成 PPT 任务,按昨天的素材清单生成。"
13 userSteer := "改用 Pillow 10 验证"
14 msgs := []provider.Message{
15 {Role: provider.RoleUser, Content: userPrompt},
16 {Role: provider.RoleAssistant, Content: "下一步:安装 pptxgenjs 并确认 Pillow。"},
17 {Role: provider.RoleUser, Content: agent.MidTurnSteerPrefix + "\n" + agent.HostRecoveryGuidanceToolFailedPrefix + ", continue unrelated work automatically."},
18 {Role: provider.RoleUser, Content: agent.MidTurnSteerPrefix + "\n" + userSteer},
19 {Role: provider.RoleAssistant, Content: "pptxgenjs 已安装成功"},
20 }
21 got := historyMessages(msgs, func(content string) string { return content })
22 var roles []string
23 var contents []string
24 for _, row := range got {
25 roles = append(roles, row.Role)
26 contents = append(contents, row.Content)
27 if strings.Contains(row.Content, "A tool failed") || strings.Contains(row.Content, "Use read-only diagnosis") {
28 t.Fatalf("host recovery guidance leaked into history: %+v", row)
29 }
30 }
31 if strings.Join(roles, ",") != "user,assistant,notice,assistant" {
32 t.Fatalf("history roles = %s, want user,assistant,notice,assistant", strings.Join(roles, ","))
33 }
34 if contents[0] != userPrompt {
35 t.Fatalf("user prompt = %q, want original task prompt", contents[0])
36 }
37 if contents[2] != "↪ "+userSteer {
38 t.Fatalf("user steer = %q, want visible mid-turn steer", contents[2])
39 }
40 }
41
41 lines GO