MCPcopy Index your code
hub / github.com/Opencode-DCP/opencode-dynamic-context-pruning / saveSessionState

Function saveSessionState

lib/state/persistence.ts:80–113  ·  view source on GitHub ↗
(
    sessionState: SessionState,
    logger: Logger,
    sessionName?: string,
)

Source from the content-addressed store, hash-verified

78}
79
80export async function saveSessionState(
81 sessionState: SessionState,
82 logger: Logger,
83 sessionName?: string,
84): Promise<void> {
85 try {
86 if (!sessionState.sessionId) {
87 return
88 }
89
90 const state: PersistedSessionState = {
91 sessionName: sessionName,
92 manualMode: !!sessionState.manualMode,
93 prune: {
94 tools: Object.fromEntries(sessionState.prune.tools),
95 messages: serializePruneMessagesState(sessionState.prune.messages),
96 },
97 nudges: {
98 contextLimitAnchors: Array.from(sessionState.nudges.contextLimitAnchors),
99 turnNudgeAnchors: Array.from(sessionState.nudges.turnNudgeAnchors),
100 iterationNudgeAnchors: Array.from(sessionState.nudges.iterationNudgeAnchors),
101 },
102 stats: sessionState.stats,
103 lastUpdated: new Date().toISOString(),
104 }
105
106 await writePersistedSessionState(sessionState.sessionId, state, logger)
107 } catch (error: any) {
108 logger.error("Failed to save session state", {
109 sessionId: sessionState.sessionId,
110 error: error?.message,
111 })
112 }
113}
114
115export async function loadSessionState(
116 sessionId: string,

Callers 9

createEventHandlerFunction · 0.90
handleSweepCommandFunction · 0.90
handleRecompressCommandFunction · 0.90
handleDecompressCommandFunction · 0.90
checkSessionFunction · 0.90
ensureSessionInitializedFunction · 0.90
injectCompressNudgesFunction · 0.90
finalizeSessionFunction · 0.90

Calls 3

errorMethod · 0.80

Tested by

no test coverage detected