rohitg00/agentmemory · error · Error

memoryIds is required

Error message

memoryIds is required

What it means

The memory_governance_delete tool requires a memoryIds argument that normalizes (via normalizeList, which accepts a comma-separated string or array) to a non-empty list of ids. An empty or absent memoryIds throws this error, protecting against accidental mass/unbounded deletes.

Source

Thrown at src/mcp/standalone.ts:171

      if (typeof fmt === "string" && fmt.trim()) {
        v.format = fmt.trim().toLowerCase();
      }
      const budget = args["token_budget"];
      if (typeof budget === "number" && Number.isFinite(budget) && budget > 0) {
        v.tokenBudget = Math.floor(budget);
      } else if (typeof budget === "string" && budget.trim()) {
        const n = Number(budget);
        if (Number.isFinite(n) && n > 0) v.tokenBudget = Math.floor(n);
      }
      return v;
    }
    case "memory_sessions": {
      v.limit = parseLimit(args["limit"], 20);
      return v;
    }
    case "memory_governance_delete": {
      const ids = normalizeList(args["memoryIds"]);
      if (ids.length === 0) throw new Error("memoryIds is required");
      v.memoryIds = ids;
      v.reason = (args["reason"] as string) || "plugin skill request";
      return v;
    }
    case "memory_export":
      return v;
    case "memory_audit": {
      v.limit = parseLimit(args["limit"], 50);
      return v;
    }
    default:
      throw new Error(`Unknown tool: ${toolName}`);
  }
}

async function handleProxy(
  v: Validated,
  handle: ProxyHandle,

View on GitHub (pinned to e04ba88819)

Solutions

  1. Pass a non-empty array of ids: memoryIds: ["id1", "id2"] or a CSV string "id1,id2".
  2. Verify the preceding search/list step actually returned ids before chaining a delete.
  3. If a bulk delete of many memories is intended, enumerate the ids explicitly — never call with an empty list.

Example fix

// before
await callTool("memory_governance_delete", { memoryIds: ids }); // ids = []
// after
if (ids.length === 0) throw new Error("nothing to delete");
await callTool("memory_governance_delete", { memoryIds: ids, reason: "cleanup" });
Defensive patterns

Strategy: validation

Validate before calling

function toIds(v) {
  const ids = Array.isArray(v) ? v : typeof v === "string" ? v.split(",") : [];
  return ids.map((s) => String(s).trim()).filter(Boolean);
}
if (toIds(args.memoryIds).length === 0) throw new Error("governance_delete needs at least one id");

Type guard

function hasMemoryIds(args: Record<string, unknown>): args is { memoryIds: string[] } & Record<string, unknown> {
  const v = args.memoryIds;
  if (Array.isArray(v)) return v.length > 0 && v.every((x) => typeof x === "string");
  return typeof v === "string" && v.split(",").some((s) => s.trim());
}

Try / catch

try {
  return await callTool("memory_governance_delete", args);
} catch (e) {
  if (e.message === "memoryIds is required") {
    throw new Error("delete aborted: no ids resolved from prior search — nothing to delete");
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling memory_governance_delete with no memoryIds key, an empty array [], an empty string "", or a string of only commas/whitespace such that normalizeList yields zero entries.

Common situations: Scripts that collected ids from a prior search which returned nothing; LLM agents deleting 'everything' by omitting the field; CSV input that was blank.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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