rohitg00/agentmemory · error · Error

content is required

Error message

content is required

What it means

The memory_save tool requires a non-empty string content argument. validate() rejects calls where content is missing, not a string, or a whitespace-only string, before any storage operation runs.

Source

Thrown at src/mcp/standalone.ts:127

  agentId?: string;
  query?: string;
  limit?: number;
  format?: string;
  tokenBudget?: number;
  memoryIds?: string[];
  reason?: string;
}

function validate(toolName: string, args: Record<string, unknown>): Validated {
  if (!IMPLEMENTED_TOOLS.has(toolName)) {
    throw new Error(`Unknown tool: ${toolName}`);
  }
  const v: Validated = { tool: toolName };
  switch (toolName) {
    case "memory_save": {
      const content = args["content"];
      if (typeof content !== "string" || !content.trim()) {
        throw new Error("content is required");
      }
      v.content = content;
      v.type = (args["type"] as string) || "fact";
      v.concepts = normalizeList(args["concepts"]);
      v.files = normalizeList(args["files"]);
      // The tool schema exposes project (and now agentId); dropping them
      // here silently broke project/agent scoping through the stdio
      // package specifically.
      if (typeof args["project"] === "string" && args["project"].trim()) {
        v.project = args["project"].trim();
      }
      if (typeof args["agentId"] === "string" && args["agentId"].trim()) {
        v.agentId = args["agentId"].trim();
      }
      return v;
    }
    case "memory_recall":
    case "memory_smart_search": {

View on GitHub (pinned to e04ba88819)

Solutions

  1. Pass a non-empty string as args.content.
  2. Stringify structured payloads with JSON.stringify before calling memory_save.
  3. Check the LLM's argument extraction — map the correct field to 'content'.

Example fix

// before
await callTool("memory_save", { text: note });
// after
await callTool("memory_save", { content: String(note).trim() });
Defensive patterns

Strategy: validation

Validate before calling

function canSave(args) {
  return typeof args.content === "string" && args.content.trim().length > 0;
}
if (!canSave(args)) throw new Error("memory_save requires non-empty content string");

Type guard

function hasContent(args: Record<string, unknown>): args is { content: string } & Record<string, unknown> {
  return typeof args.content === "string" && args.content.trim().length > 0;
}

Try / catch

try {
  return await callTool("memory_save", args);
} catch (e) {
  if (e.message === "content is required") {
    return await callTool("memory_save", { ...args, content: JSON.stringify(args) });
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling memory_save with args lacking 'content', content as a non-string (number, object, null), or content: " " (whitespace only).

Common situations: LLM tool calls that put the memory text under a wrong key (e.g. 'text' or 'memory') or omit it entirely; programmatic callers passing structured objects instead of strings; empty template fields in automation.

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/5cee2e5e07c51faa. Report an issue: GitHub.