Why: Allow consumers to download an immutable module revision without nested source checkouts or local path replacements. Evidence: SELF package tests and the prior canonical-path rejection are recorded in the Dev dependency-workspace task card; remote consumption is replayed against the committed candidate. Impact: Change the module identity and its Go imports while preserving API behavior. Existing historical submodule revisions remain buildable. Refs: Versioned dependencies U1/U3; feature/dependency-workspace
44 lines
1.9 KiB
Go
44 lines
1.9 KiB
Go
package ctxasm
|
||
|
||
import (
|
||
"strings"
|
||
"testing"
|
||
|
||
agentllm "git-ssh.u1680832.nyat.app/weichen/Agent-Native.git/runtime/llm"
|
||
core "git-ssh.u1680832.nyat.app/weichen/Agent-System-Core.git"
|
||
)
|
||
|
||
// 交错思考模型(MiniMax 等)要求历史 assistant 原样回传 <think>;
|
||
// 关闭时不回传(默认兼容旧行为)。思考块只进请求,不落库。
|
||
func TestThinkReplayWrapsAssistantHistory(t *testing.T) {
|
||
hist := []core.Message{
|
||
{ID: "m1", Role: core.RoleUser, Parts: []core.Part{{Type: core.PartText, Text: "总结"}}},
|
||
{ID: "m2", Role: core.RoleAssistant, Parts: []core.Part{
|
||
{Type: core.PartThinking, Text: "先读材料。", Process: true},
|
||
{Type: core.PartText, Text: "结论是先入库。", Process: true},
|
||
{Type: core.PartToolCall, ToolCall: &core.ToolCallPart{ID: "c1", Name: "run_python", Arguments: "{}"}},
|
||
{Type: core.PartToolResult, ToolResult: &core.ToolResultPart{CallID: "c1", Status: "ok", Summary: "done"}},
|
||
{Type: core.PartText, Text: "已完成。"},
|
||
}},
|
||
}
|
||
on, _ := AssembleInput(core.AgentProfile{}, core.EffectiveSettings{}, hist, fakeUser("继续"), nil, nil, nil, nil, nil, nil, AssembleOptions{ThinkReplay: true})
|
||
var sawThink int
|
||
for _, m := range on {
|
||
if m.Role == agentllm.RoleAssistant && strings.HasPrefix(m.Content, "<think>") {
|
||
sawThink++
|
||
if !strings.Contains(m.Content, "</think>") || !strings.Contains(m.Content, "先读材料。") {
|
||
t.Fatalf("think block malformed: %q", m.Content)
|
||
}
|
||
}
|
||
}
|
||
if sawThink == 0 {
|
||
t.Fatalf("ThinkReplay=on should inject <think> into assistant history: %+v", on)
|
||
}
|
||
off, _ := AssembleInput(core.AgentProfile{}, core.EffectiveSettings{}, hist, fakeUser("继续"), nil, nil, nil, nil, nil, nil, AssembleOptions{})
|
||
for _, m := range off {
|
||
if m.Role == agentllm.RoleAssistant && strings.Contains(m.Content, "<think>") {
|
||
t.Fatalf("ThinkReplay=off must not inject think blocks: %q", m.Content)
|
||
}
|
||
}
|
||
}
|