Recipe 05

Memory files

In Anthropic's testing, file-based memory improved Fable's game performance 3× more than it improved Opus 4.8's. Fable doesn't just tolerate a notebook — it uses one.

The memory tool

The memory tool is client-side: Claude issues view / create / str_replace / insert / delete / rename commands against a /memories directory, and your code does the file I/O — so memory persists wherever you decide it lives.

response = client.messages.create(
    model="claude-fable-5",
    max_tokens=16000,
    tools=[{"type": "memory_20250818", "name": "memory"}],
    messages=[{"role": "user", "content": "Remember: deploys go through staging first."}],
)

The Python SDK gives you a backend skeleton — subclass it and the tool runner handles the loop:

from anthropic.lib.tools import BetaAbstractMemoryTool

class FileMemory(BetaAbstractMemoryTool):
    def view(self, command): ...        # read a file or list the directory
    def create(self, command): ...      # write a new memory file
    def str_replace(self, command): ... # edit in place
    def insert(self, command): ...
    def delete(self, command): ...
    def rename(self, command): ...

runner = client.beta.messages.tool_runner(
    model="claude-fable-5",
    max_tokens=16000,
    tools=[FileMemory()],
    messages=[{"role": "user", "content": task}],
)

The unlock is the prompt, not the tool

Fable is conservative about reaching for capabilities that need a "decide to use this" step. Tell it when, in one line of system prompt:

"Before any task longer than a few turns, check your memory directory for relevant prior context. Write new findings to it as you go — future sessions depend on your notes."

What good memory looks like

  • Many small files beat one growing log — name them by topic so view on the directory is a useful index.
  • Facts, not transcripts. The note should say what was learned, not what was said.
  • Never store secrets (keys, passwords, tokens) in memory files, and partition per-user directories in multi-user systems — the reference implementation has no access control.

Moral: an agent without notes starts every morning with amnesia. Fable takes good notes — let it.

This recipe in about a minute