mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-11-01 06:47:29 +00:00
记忆层: - MemoryBlock 承载 FrameTS/PageSeq/PageKind/BlockRole/CallID - coldcontext 归档与回填按完整页传递,工具调用参数和配对键不丢失 - 召回先估算总 token,超预算时按全局页相似度标记 inactive - inactive 仅是 context 渲染期状态,不落盘、不进入 coldcontext,Prune 后重置 - Peek/确认/Remove 两阶段召回,失败保留冷上下文副本 - stablemem 记录 last_recalled_at,删块连带清理边 命名: - internal/memory/document → internal/memory/coldcontext - Doc/DocEvent/DocHit → ColdDoc/ColdEvent/ColdHit - ContextToColdContext/RecentColdContexts/FindColdContexts - 保留既有 JSON 标签、doc_ 文件前缀与 doc_count 状态键,兼容存量数据 安全治理: - 工具策略门禁、安全配置、事件总线发布者身份与入站脱敏 - 声明式 SecurityAPI 与 QQ owner/guest profile - 日志保留策略与相关 e2e/回归判据 验证:go build ./...、go vet ./...、go test ./...(62 包); 生产副本 e2e:7013 块迁移后 ID/向量/指纹 0 变化、0 缺失。
47 lines
1.5 KiB
Go
47 lines
1.5 KiB
Go
package core
|
|
|
|
// L2 预填充必须同时给出「发生了什么」与「内容是什么」。
|
|
//
|
|
// 现场:召回命中「已回复老大:原来是「魔芋爽」这个谐音梗」——模型读得懂
|
|
// "我回复过",却不知道梗本身,于是答"不知道"。真实内容在事件的文本块与
|
|
// 工具回执里,摘要行永远不含它。
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/JianFeeeee/HologramAgent/internal/memory"
|
|
"github.com/JianFeeeee/HologramAgent/internal/memory/coldcontext"
|
|
)
|
|
|
|
func TestDocBodyExcerptPicksToolResult(t *testing.T) {
|
|
d := &coldcontext.ColdDoc{
|
|
Events: []coldcontext.ColdEvent{{
|
|
Timestamp: time.Now(),
|
|
Blocks: []memory.MemoryBlock{
|
|
{Modality: "text", Text: "已回复老大:原来是这个谐音梗。"},
|
|
},
|
|
ToolResults: []coldcontext.ToolResultItem{
|
|
{Name: "qq_get_message", Output: `{"content":"因为魔芋爽","message_id":123}`},
|
|
},
|
|
}},
|
|
}
|
|
got := docBodyExcerptForPrompt(d, 80)
|
|
if !strings.Contains(got, "魔芋爽") {
|
|
t.Fatalf("正文摘录应来自工具回执并含真实内容,实际: %q", got)
|
|
}
|
|
if strings.Contains(got, "{") {
|
|
t.Fatalf("JSON 回执应被压成可读文本,实际: %q", got)
|
|
}
|
|
}
|
|
|
|
func TestToolResultExcerptPlainText(t *testing.T) {
|
|
if got := toolResultExcerptForPrompt("第一行\n第二行"); got != "第一行" {
|
|
t.Fatalf("非 JSON 回执应取首行,实际: %q", got)
|
|
}
|
|
if got := toolResultExcerptForPrompt(""); got != "" {
|
|
t.Fatalf("空回执应为空,实际: %q", got)
|
|
}
|
|
}
|