fix: graceful ctrl+c shutdown and await session-end memory writes
This commit is contained in:
@@ -53,7 +53,7 @@ export class SessionBridge {
|
||||
}
|
||||
|
||||
/** Remove a WS connection. Does NOT destroy the session (persists in SQLite). */
|
||||
disconnect(connectionId: string): void {
|
||||
async disconnect(connectionId: string): Promise<void> {
|
||||
const client = this.clients.get(connectionId);
|
||||
if (client) {
|
||||
// Only remove the agent if no other clients share the session
|
||||
@@ -73,15 +73,17 @@ export class SessionBridge {
|
||||
writeToMemory: summaryConfig.write_to_memory,
|
||||
memoryNamespace: summaryConfig.memory_namespace,
|
||||
};
|
||||
void summarizeSessionOnEnd({
|
||||
agent,
|
||||
sessionId: client.sessionId,
|
||||
history,
|
||||
config: mappedConfig,
|
||||
memoryStore: this.config.memoryStore,
|
||||
}).catch((error) => {
|
||||
try {
|
||||
await summarizeSessionOnEnd({
|
||||
agent,
|
||||
sessionId: client.sessionId,
|
||||
history,
|
||||
config: mappedConfig,
|
||||
memoryStore: this.config.memoryStore,
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('Session end summary failed:', error);
|
||||
});
|
||||
}
|
||||
}
|
||||
this.agents.delete(client.sessionId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user