mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-10-04 00:03:59 +00:00
fix: LLM 工具循环 400、中断消息注入、ConPTY 终端支持
- agent: 工具轮请求尾部补 user 占位(zen 网关强制),tool 消息正确配对 - agent: 工具提醒/中断以 system 角色注入并带 [中断消息] 前缀,不进用户履历;系统提示词说明中断消息格式 - agentcli: 基于 ConPTY 的交互式终端(ptywin fork),terminal_create/read/write/resize/close/watch - webui: server 输出通道适配器(保留 reasoning_content/disable_thinking) - GUI: 沉浸式标题栏、icon 圆角重制、mascot 等打磨
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package pipeline
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@ -117,6 +118,71 @@ func TestDistillOnce(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Phase 4: 新记录无需等待 RetentionDays,下一 tick 立即蒸馏(文档所述 10min 频率)
|
||||
func TestDistillOnceFreshRecords(t *testing.T) {
|
||||
db, err := memory.NewGraphDB(filepath.Join(t.TempDir(), "test.db"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
dir := t.TempDir()
|
||||
d := NewDistiller(db, dir, DistillerConfig{
|
||||
Interval: 10 * time.Minute,
|
||||
RetentionDays: 7,
|
||||
BatchSize: 50,
|
||||
})
|
||||
d.Append("sess1", "user", "我的名字是李四")
|
||||
d.Append("sess1", "assistant", "你好李四!")
|
||||
|
||||
if len(d.records) != 2 {
|
||||
t.Fatalf("expected 2 fresh records, got %d", len(d.records))
|
||||
}
|
||||
|
||||
d.distillOnce()
|
||||
if len(d.records) != 0 {
|
||||
t.Errorf("fresh records should be distilled on next tick (no retention gate), got %d remaining", len(d.records))
|
||||
}
|
||||
|
||||
// 二次蒸馏不重复(已蒸馏记录已被移除)
|
||||
d.distillOnce()
|
||||
if len(d.records) != 0 {
|
||||
t.Errorf("second distill should be no-op, got %d records", len(d.records))
|
||||
}
|
||||
}
|
||||
|
||||
// Phase 4: BatchSize 限制每 tick 处理前 N 条,未蒸馏记录留待下个 tick
|
||||
func TestDistillOnceBatchLimit(t *testing.T) {
|
||||
db, err := memory.NewGraphDB(filepath.Join(t.TempDir(), "test.db"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
dir := t.TempDir()
|
||||
d := NewDistiller(db, dir, DistillerConfig{
|
||||
Interval: 10 * time.Minute,
|
||||
RetentionDays: 7,
|
||||
BatchSize: 3,
|
||||
})
|
||||
for i := 0; i < 10; i++ {
|
||||
d.Append("sess1", "user", fmt.Sprintf("第 %d 条消息内容", i))
|
||||
}
|
||||
|
||||
d.distillOnce()
|
||||
if len(d.records) != 7 {
|
||||
t.Fatalf("expected 7 records remaining after batch 3, got %d", len(d.records))
|
||||
}
|
||||
|
||||
// 后续 tick 继续消化,最终全部蒸馏
|
||||
for i := 0; i < 5 && len(d.records) > 0; i++ {
|
||||
d.distillOnce()
|
||||
}
|
||||
if len(d.records) != 0 {
|
||||
t.Errorf("all records should be distilled after several ticks, got %d remaining", len(d.records))
|
||||
}
|
||||
}
|
||||
|
||||
func TestExtractKeyTriples(t *testing.T) {
|
||||
tests := []struct {
|
||||
user string
|
||||
|
||||
Reference in New Issue
Block a user