fix: auto-persist cleaned history when orphan tool messages detected (#128)

sanitizeHistory now returns dropped count so callers know when orphaned
tool_use/tool_result messages were removed. When orphans are found in
buildMessages, the full session history is sanitized and persisted,
preventing repeated warnings on every request.

- Add SetHistory() to SessionStore interface and both implementations
- Adapt memoryflush caller to new two-return signature
- Change sanitize log level from Warn to Debug
This commit is contained in:
Viet Tran authored and GitHub committed 2026-03-11 07:57:54 +07:00
1 parent cc00a6f193
commit cd2e407b29
6 files changed
+57 -16

No files matched your search

+2 -1
View File
@@ -132,7 +132,8 @@ func (l *Loop) runMemoryFlush(ctx context.Context, sessionKey string, settings *
if len(recentHistory) > 10 {
recentHistory = recentHistory[len(recentHistory)-10:]
}
messages = append(messages, sanitizeHistory(recentHistory)...)
sanitized, _ := sanitizeHistory(recentHistory)
messages = append(messages, sanitized...)
// Flush prompt
messages = append(messages, providers.Message{