mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-14 22:09:37 +08:00
enforce memory recall hints and long-term memory write gating
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user