Files
HomeAgent/internal/sdk/indexer.go
JianFeeeee 1dc32be736 fix(memory): 召回可用性——L2 片段带正文 + WebUI 上下文走双路
① L2 预填充此前只给摘要行('已回复老大:原来是这个谐音梗'),模型读得懂
   '我回复过'却不知道梗是什么 ⇒ 召回命中仍答不知道。现取两段候选
   (事件文本块 + 工具回执),JSON 回执先提取字符串值再压成单行。
② WebUI「上下文」页只显示 L3,而 L3 有 72h 冷化延迟 ⇒ 冷化没跑起来时
   面板永远'无上下文',看着像召回彻底坏了(实际 L2 一直有命中)。
   现 IndexerAPI 带上 L2 片段(与模型预填充同一 QueryScored),前端两路并列。
判据:internal/agent/core/crossmodal_body_test.go
2026-10-27 13:04:19 +08:00

32 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package sdk
// IndexerAPI exposes the memory context indexer.
type IndexerAPI interface {
BuildContext(q string) (*IndexContext, error)
FormatContext(ctx *IndexContext) string
GetToolDefinitions() []map[string]interface{}
BuildToolPrompt() string
}
// IndexContext is a neutral snapshot of the injected memory context.
type IndexContext struct {
Entities []Entity `json:"entities"`
Relations []Relation `json:"relations"`
Summary string `json:"summary"`
TokenEstimate int `json:"token_estimate"`
// Docs 是 **L2 冷上下文**那一路的结果(文档/媒体片段)。
//
// 为什么放在同一个结构里:真实召回是 L2 + L3 **双路**,插件若只看到 L3
// 就会出现「图里没东西 ⇒ 面板显示无上下文」的假象(L3 有 72h 冷化延迟,
// 而 L2 一直是活的)。诊断面板必须复现模型真实收到的两路。
Docs []DocSnippet `json:"docs"`
}
// DocSnippet 是 L2 命中的一条片段。
type DocSnippet struct {
ID string `json:"id"`
When string `json:"when"`
Text string `json:"text"`
Score float64 `json:"score"`
}