MCPcopy Create free account
hub / github.com/Roy3838/Observer / endSession

Method endSession

app/src/utils/IterationStore.ts:369–391  ·  view source on GitHub ↗
(agentId: string)

Source from the content-addressed store, hash-verified

367 }
368
369 public async endSession(agentId: string): Promise<void> {
370 const sessionId = this.currentSessions.get(agentId);
371 if (sessionId) {
372 // Save current session to persistent storage
373 await this.saveSessionToIndexedDB(agentId, sessionId);
374
375 // Clean up current session data
376 this.currentSessions.delete(agentId);
377 this.sessionIterationCounts.delete(sessionId);
378
379 // Remove iterations from memory (they're now persisted)
380 const iterationsToRemove = Array.from(this.iterations.values())
381 .filter(iteration => iteration.sessionId === sessionId);
382
383 iterationsToRemove.forEach(iteration => {
384 this.iterations.delete(iteration.id);
385 });
386
387 await this.saveToIndexedDB();
388
389 Logger.info('IterationStore', `Ended session ${sessionId} for agent ${agentId}`);
390 }
391 }
392
393 public getIterationsForAgent(agentId: string): IterationData[] {
394 // Only return current session iterations (from memory)

Callers 1

stopAgentLoopFunction · 0.80

Calls 4

saveToIndexedDBMethod · 0.95
deleteMethod · 0.80
infoMethod · 0.80

Tested by

no test coverage detected