Memory Tool
Definition
An Anthropic-provided, client-side, file-based tool (memory_20250818) that lets Claude request file operations against a developer-controlled /memories store, giving agents persistent memory outside the context window.
Key points
- Tool entry:
{"type": "memory_20250818", "name": "memory"}—namemust bememory; no input schema (Anthropic-provided tool). - Generally available on the Messages API — NO beta header required. (SDK helpers live in the beta namespace even though the tool is GA.)
- Available on all Claude 4 and later models. ZDR-eligible.
- Client-side: Claude only requests file operations; your app executes them against storage you control and returns a
tool_result./memoriesis a prefix your handler maps onto real storage. - Six client-side commands (dispatch on
input.command):view—{command, path, view_range?}; dir listing up to 2 levels deep, file view with 6-char line numbers.create—{command, path, file_text}; "creates or overwrites."str_replace—{command, path, old_str, new_str?}(omitnew_str= delete);old_strmust be unique.insert—{command, path, insert_line, insert_text}; inserted afterinsert_line,0= beginning.delete—{command, path}; recursive for dirs; cannot delete/memoriesroot.rename—{command, old_path, new_path}; won't overwrite existing dest; cannot rename/memoriesroot.
- Auto-injected system prompt when present:
"IMPORTANT: ALWAYS VIEW YOUR MEMORY DIRECTORY BEFORE DOING ANYTHING ELSE."+ memory protocol +"ASSUME INTERRUPTION...". - Pairs with Context Editing (
memory_20250818+clear_tool_uses_20250919): near the clearing threshold Claude is warned to write important info to memory before tool results are cleared. Also pairs with Server-side Compaction.
Why it matters for the exam
- The product implementation of Structured Note-Taking for long-running agents. Expect the GA/no-beta-header detail, the
/memoriesprefix, the six commands, and the pairing with context editing/compaction.
Common gotchas
- Path-traversal protection is the developer's responsibility —
/memories/../../secrets.envcan escape. Validate every path resolves inside/memories; reject../,..\\, and URL-encoded%2e%2e%2f. - It's GA — no beta header (unlike Context Editing, which needs
context-management-2025-06-27). Don't conflate the two. - The tool is client-side: Claude never touches your storage directly; your handler does.
See also
Sources
Referenced by
Practice questions optional · AI
Generate fresh practice questions about this concept with AI. These are not vault-verified.