MCPcopy Create free account
hub / github.com/cortexkit/magic-context / cleanupSessions

Function cleanupSessions

packages/plugin/scripts/longmemeval/runner.ts:739–762  ·  view source on GitHub ↗
(args: {
    client: OpencodeClient;
    config: RunnerConfig;
    questionState: QuestionRunState;
    state: RunnerStateFile;
    questionId: string;
})

Source from the content-addressed store, hash-verified

737}
738
739async function cleanupSessions(args: {
740 client: OpencodeClient;
741 config: RunnerConfig;
742 questionState: QuestionRunState;
743 state: RunnerStateFile;
744 questionId: string;
745}): Promise<void> {
746 const { client, config, questionState, state, questionId } = args;
747 if (!config.cleanupSessions || questionState.cleanupCompleted) {
748 return;
749 }
750
751 for (const sessionId of questionState.createdSessionIds) {
752 try {
753 await deleteSession(client, config, sessionId);
754 } catch (error) {
755 await appendLog(config.paths.logFile, `Cleanup failed for ${questionId}/${sessionId}: ${asError(error).message}`);
756 }
757 }
758 questionState.cleanupCompleted = true;
759 questionState.updatedAt = nowIso();
760 state.inProgress[questionId] = questionState;
761 await persistState(config, state);
762}
763
764async function markQuestionCompleted(args: {
765 config: RunnerConfig;

Callers 1

processQuestionFunction · 0.85

Calls 5

deleteSessionFunction · 0.85
appendLogFunction · 0.85
nowIsoFunction · 0.85
persistStateFunction · 0.85
asErrorFunction · 0.70

Tested by

no test coverage detected