fix(session): propagate compact error from Save

Save() was swallowing the error returned by Compact and always
returning nil. Callers checking Save's return value would never
see a compaction failure. Return the error directly so the agent
loop can log or handle it as needed.
This commit is contained in:
xiaoen 2026-03-07 21:16:58 +08:00
parent 209d0644f9
commit 1434edcb76

View file

@ -72,10 +72,7 @@ func (b *JSONLBackend) TruncateHistory(key string, keepLast int) {
// immediately, the data is already durable. Save runs compaction to reclaim // immediately, the data is already durable. Save runs compaction to reclaim
// space from logically truncated messages (no-op when there are none). // space from logically truncated messages (no-op when there are none).
func (b *JSONLBackend) Save(key string) error { func (b *JSONLBackend) Save(key string) error {
if err := b.store.Compact(context.Background(), key); err != nil { return b.store.Compact(context.Background(), key)
log.Printf("session: compact %s: %v", key, err)
}
return nil
} }
// Close releases resources held by the underlying store. // Close releases resources held by the underlying store.