enforce memory recall hints and long-term memory write gating

This commit is contained in:
DBT
2026-02-23 15:42:20 +00:00
parent d181525b88
commit 15b4d7cccc
2 changed files with 38 additions and 0 deletions

View File

@@ -94,6 +94,11 @@ func (t *MemoryWriteTool) Execute(ctx context.Context, args map[string]interface
formatted := formatMemoryLine(content, importance, source, tags)
if (kind == "longterm" || kind == "memory" || kind == "permanent") && !allowLongTermWrite(importance, tags) {
kind = "daily"
formatted = formatMemoryLine(content, importance, source, append(tags, "downgraded:longterm_gate"))
}
switch kind {
case "longterm", "memory", "permanent":
path := filepath.Join(t.workspace, "MEMORY.md")
@@ -179,3 +184,17 @@ func formatMemoryLine(content, importance, source string, tags []string) string
}
return fmt.Sprintf("[%s] %s", strings.Join(meta, " | "), content)
}
func allowLongTermWrite(importance string, tags []string) bool {
if strings.ToLower(strings.TrimSpace(importance)) == "high" {
return true
}
for _, t := range tags {
s := strings.ToLower(strings.TrimSpace(t))
switch s {
case "preference", "decision", "rule", "policy", "identity":
return true
}
}
return false
}