task lifecycle + heartbeat resilience: preserve archived done tasks and reset heartbeat session on pairing-loop errors

This commit is contained in:
DBT
2026-03-02 10:31:31 +00:00
parent eb4f1dc82a
commit d2f680debb
3 changed files with 46 additions and 0 deletions

View File

@@ -321,6 +321,24 @@ func (sm *SessionManager) rewriteSessionFileLocked(session *Session) error {
return nil
}
func (sm *SessionManager) ResetSession(key string) {
sm.mu.RLock()
session, ok := sm.sessions[key]
sm.mu.RUnlock()
if !ok {
return
}
session.mu.Lock()
session.Messages = []providers.Message{}
session.Summary = ""
session.Updated = time.Now()
if sm.storage != "" {
_ = sm.rewriteSessionFileLocked(session)
_ = sm.writeOpenClawSessionsIndex()
}
session.mu.Unlock()
}
func (sm *SessionManager) TruncateHistory(key string, keepLast int) {
sm.mu.RLock()
session, ok := sm.sessions[key]