blank session cleanup improvements
- make the blank session cleanup system optionally fetch full message histories for each session to better judge if it's blank - make a command that does the deep clean, keep the clean that happens on new session creation shallow
This commit is contained in:
committed by
Alexis Purslane
parent
f633d75005
commit
50676416ed
@@ -407,27 +407,6 @@ async function deleteSession(instanceId: string, sessionId: string): Promise<voi
|
||||
}
|
||||
}
|
||||
|
||||
async function cleanupBlankSessions(instanceId: string, excludeSessionId?: string): Promise<void> {
|
||||
const instanceSessions = sessions().get(instanceId)
|
||||
if (!instanceSessions) return
|
||||
|
||||
const deletionPromises: Promise<void>[] = []
|
||||
|
||||
for (const [sessionId, session] of instanceSessions) {
|
||||
if (sessionId === excludeSessionId) continue
|
||||
if (!isBlankSession(session, instanceId)) continue
|
||||
|
||||
deletionPromises.push(deleteSession(instanceId, sessionId).catch((error) => {
|
||||
console.error(`Failed to delete blank session ${sessionId}:`, error)
|
||||
}))
|
||||
}
|
||||
|
||||
if (deletionPromises.length > 0) {
|
||||
console.log(`Cleaning up ${deletionPromises.length} blank sessions`)
|
||||
await Promise.all(deletionPromises)
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchAgents(instanceId: string): Promise<void> {
|
||||
const instance = instances().get(instanceId)
|
||||
if (!instance || !instance.client) {
|
||||
|
||||
Reference in New Issue
Block a user