{"record":{"id":"a0f2b6c61ff687f6","repo":"rohitg00/agentmemory","slug":"session-not-found","errorCode":"session_not_found","errorMessage":"session_not_found","messagePattern":"session_not_found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/functions/summarize.ts","lineNumber":249,"sourceCode":"  kv: StateKV,\n  provider: MemoryProvider,\n  metricsStore?: MetricsStore,\n): void {\n  sdk.registerFunction(\"mem::summarize\", \n    async (data: { sessionId: string } | undefined) => {\n      const startMs = Date.now();\n      if (!data || typeof data.sessionId !== \"string\" || !data.sessionId.trim()) {\n        return { success: false, error: \"sessionId is required\" };\n      }\n      const sessionId = data.sessionId.trim();\n\n      const session = await kv.get<Session>(KV.sessions, sessionId);\n      if (!session) {\n        logger.warn(\"Session not found for summarize\", {\n          sessionId,\n        });\n        return { success: false, error: \"session_not_found\" };\n      }\n\n      const observations = await kv.list<CompressedObservation>(\n        KV.observations(sessionId),\n      );\n      const compressed = observations.filter((o) => o.title);\n\n      if (compressed.length === 0) {\n        logger.info(\"No observations to summarize\", {\n          sessionId,\n        });\n        return { success: false, error: \"no_observations\" };\n      }\n\n      if (provider.name === \"noop\") {\n        logger.info(\"Summarize skipped — no LLM provider configured\", {\n          sessionId,\n        });\n        return {","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/rohitg00/agentmemory/blob/e04ba88819c365c9acf9d6661ea802143e728bd6/src/functions/summarize.ts#L231-L267","documentation":"The mem::summarize function loads the target session from KV storage before summarizing. If no Session exists for the given sessionId, it returns success:false with error 'session_not_found'. This guards against summarizing observations for a session that was never recorded or was deleted/exported away.","triggerScenarios":"Calling mem::summarize (via sdk.trigger, MCP tool, or REST) with a sessionId for which kv.get(KV.sessions, sessionId) returns null — session never created, wrong id, or data store wiped/replaced.","commonSituations":"Typo or stale sessionId cached in the client; summarizing before any observations were stored; pointing the daemon at a fresh data directory (new ./data/state_store.db); session purged by retention/cleanup.","solutions":["Verify the sessionId exists (list sessions or check the store) and correct the id.","Ensure observations were recorded for that session before calling summarize.","Re-create the session / re-run the capture flow if the data was deleted.","Confirm the daemon is pointed at the same data directory the session was written to."],"exampleFix":"// before\nawait sdk.trigger({ function_id: \"mem::summarize\", payload: { sessionId: staleId } });\n// after\nconst session = await sdk.trigger({ function_id: \"mem::session::get\", payload: { sessionId } });\nif (session.success) await sdk.trigger({ function_id: \"mem::summarize\", payload: { sessionId } });","handlingStrategy":"validation","validationCode":"const sessions = await sdk.trigger({ function_id: \"mem::session::list\", payload: {} });\nif (!sessions.items?.some((s) => s.id === sessionId)) {\n  throw new Error(`Unknown sessionId: ${sessionId}`);\n}","typeGuard":"function isSessionNotFound(res: unknown): res is { success: false; error: \"session_not_found\" } {\n  return typeof res === \"object\" && res !== null && (res as any).error === \"session_not_found\";\n}","tryCatchPattern":"const res = await sdk.trigger({ function_id: \"mem::summarize\", payload: { sessionId } });\nif (isSessionNotFound(res)) {\n  // recreate session or correct the id before retrying\n}","preventionTips":["Only pass sessionIds obtained from session listing/creation APIs, never hand-typed.","Check the session exists right before summarizing.","Remember summarize requires prior observations — record them first.","Verify the daemon's data directory is the one that holds your sessions."],"tags":["session","not-found","state","kv-store"],"backgroundTag":"resource-not-found","analyzedSha":"e04ba88819c365c9acf9d6661ea802143e728bd6","analyzedAt":"2026-08-30T01:07:40.754Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}