diegosouzapw/OmniRoute · error

Failed to delete memory

Error message

Failed to delete memory: ${id}

What it means

Persistence failure in handleMemoryDelete: ownership passed but deleteMemory(id) returned falsy — the row was not deleted, most often because it was already removed (concurrent delete) or the DB write failed. The memory still exists from the caller's perspective; retrying after a re-list is safe.

Solutions

  1. Treat as success if a prior delete already removed the memory (verify via list)
  2. Retry the delete after confirming the id still exists
  3. Check server logs for SQLite errors if it keeps failing
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at src/lib/skills/memoryBuiltins.ts:153 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/3957d16aeb2625c0. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/skills/memoryBuiltins.ts:153

  return {
    success: true,
    data: {
      memories: limited.map((m) => memoryToPlain(m)),
      count: limited.length,
      totalTokens: limited.reduce((sum, m) => sum + Math.ceil(m.content.length / 4), 0),
    },
    context: context.apiKeyId,
  };
}

async function handleMemoryDelete(input: Record<string, unknown>, context: { apiKeyId: string }) {
  const { id } = input as { id: string };
  if (!id || typeof id !== "string") throw new Error("Missing required field: id");

  await assertOwner(id, context.apiKeyId);

  const ok = await deleteMemory(id);
  if (!ok) throw new Error(`Failed to delete memory: ${id}`);

  return {
    success: true,
    id,
    message: "Memory deleted successfully",
    context: context.apiKeyId,
  };
}

export const memoryBuiltinHandlers = {
  [MEMORY_SAVE_TOOL_NAME]: handleMemorySave,
  [MEMORY_UPDATE_TOOL_NAME]: handleMemoryUpdate,
  [MEMORY_SEARCH_TOOL_NAME]: handleMemorySearch,
  [MEMORY_DELETE_TOOL_NAME]: handleMemoryDelete,
} as const;

const MEMORY_SAVE_DESCRIPTION = [
  "Save a memory entry for the current API key. Creates a new entry, or updates the existing",

View on GitHub (pinned to a179ffed5b)