rohitg00/agentmemory · error

session_not_found

session_not_found

Error message

session_not_found

What it means

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.

Source

Thrown at src/functions/summarize.ts:249

  kv: StateKV,
  provider: MemoryProvider,
  metricsStore?: MetricsStore,
): void {
  sdk.registerFunction("mem::summarize", 
    async (data: { sessionId: string } | undefined) => {
      const startMs = Date.now();
      if (!data || typeof data.sessionId !== "string" || !data.sessionId.trim()) {
        return { success: false, error: "sessionId is required" };
      }
      const sessionId = data.sessionId.trim();

      const session = await kv.get<Session>(KV.sessions, sessionId);
      if (!session) {
        logger.warn("Session not found for summarize", {
          sessionId,
        });
        return { success: false, error: "session_not_found" };
      }

      const observations = await kv.list<CompressedObservation>(
        KV.observations(sessionId),
      );
      const compressed = observations.filter((o) => o.title);

      if (compressed.length === 0) {
        logger.info("No observations to summarize", {
          sessionId,
        });
        return { success: false, error: "no_observations" };
      }

      if (provider.name === "noop") {
        logger.info("Summarize skipped — no LLM provider configured", {
          sessionId,
        });
        return {

View on GitHub (pinned to e04ba88819)

Solutions

  1. Verify the sessionId exists (list sessions or check the store) and correct the id.
  2. Ensure observations were recorded for that session before calling summarize.
  3. Re-create the session / re-run the capture flow if the data was deleted.
  4. Confirm the daemon is pointed at the same data directory the session was written to.

Example fix

// before
await sdk.trigger({ function_id: "mem::summarize", payload: { sessionId: staleId } });
// after
const session = await sdk.trigger({ function_id: "mem::session::get", payload: { sessionId } });
if (session.success) await sdk.trigger({ function_id: "mem::summarize", payload: { sessionId } });
Defensive patterns

Strategy: validation

Validate before calling

const sessions = await sdk.trigger({ function_id: "mem::session::list", payload: {} });
if (!sessions.items?.some((s) => s.id === sessionId)) {
  throw new Error(`Unknown sessionId: ${sessionId}`);
}

Type guard

function isSessionNotFound(res: unknown): res is { success: false; error: "session_not_found" } {
  return typeof res === "object" && res !== null && (res as any).error === "session_not_found";
}

Try / catch

const res = await sdk.trigger({ function_id: "mem::summarize", payload: { sessionId } });
if (isSessionNotFound(res)) {
  // recreate session or correct the id before retrying
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of rohitg00/agentmemory@e04ba88819 (2026-08-30). Data as JSON: /api/errors/a0f2b6c61ff687f6. Report an issue: GitHub.