Agent Memory

Add Agent Memory support

Implement progressive memory disclosure in an agent harness.

If your harness already stores memory as Markdown, support requires defining what enters context and how the agent discovers each deeper directory.

1. Locate and validate the memory root

Choose the directory that represents one memory. Its location and scope are up to the harness: per agent, user, project, or another unit.

Require MEMORY.md at the root. Every non-hidden subdirectory containing Markdown memory, directly or in a descendant directory, must also contain MEMORY.md.

The directory must remain available to the file or memory tools used for selective reads.

2. Load core memory

At prompt compilation, read every .md file directly inside the root. Include those contents in an always-visible memory section.

Do not recursively load Markdown from subdirectories.

<memory root="/path/to/memory">
  <file name="MEMORY.md">...</file>
  <file name="persona.md">...</file>
  <file name="human.md">...</file>
</memory>

The wrapper format is not standardized. XML, JSON, Markdown headings, or another clear boundary all work.

3. Surface the next memory layer

Tell the agent which immediate child memory directories exist without loading their contents. The current MEMORY.md may index them, or the harness may provide an immediate-child listing or memory search.

When the agent follows a child directory, it reads that directory’s MEMORY.md first. That file provides directory-level context and points toward files or another layer of child directories.

A recursively injected file tree is compatible, but level-by-level discovery better preserves the meaning of directory depth.

4. Support selective reads

Let the agent read individual external-memory files when they become relevant. Existing file tools are sufficient when they can reach the memory root. Sandboxed or remote harnesses may expose a dedicated memory-read tool instead.

Checklist

  • The root contains MEMORY.md.
  • Every nested memory directory contains MEMORY.md.
  • Every root .md file is in context.
  • Nested Markdown content is absent from the initial context.
  • The agent can discover immediate child memory directories.
  • The agent can read individual external-memory files.
  • No frontmatter, git repository, write capability, or storage backend is required.

For optional features such as git history, budget enforcement, generated indexes, and refresh behavior, see Implementation patterns.