Advanced Agents 8 min read

MemPalace Specialist Agents — Domain Memory Without Letta's Subscription

A complete guide to setting up domain-focused specialist agents in MemPalace — roles that build genuine expertise over time by maintaining their own memory wing and AAAK-compressed diary. Includes example configurations, diary entry formats, and a direct cost comparison with Letta.

The Core Concept

A MemPalace specialist agent is an AI role — code reviewer, system architect, security analyst, ops engineer — that maintains its own dedicated palace wing and a personal diary written in AAAK format. Unlike a general-purpose AI that starts each session without context, a specialist agent reads its diary before beginning work. It enters each session knowing every relevant pattern it has identified, every decision it has participated in, and every problem it has seen before.

The agent builds genuine expertise over time. A code reviewer that has processed 200 pull requests over three months carries a concrete record of every recurring bug pattern, every near-miss, and every architectural concern it raised. That history is small in token terms but significant in practical value.

Cost Comparison Letta charges $20–200 per month for agent-managed memory infrastructure. MemPalace implements the same capability with a JSON configuration file and a palace wing. The cost difference is $0 vs $240–2,400 per year — with MemPalace running entirely on your local machine.

How the Mechanism Works

Each agent is defined by a JSON file in ~/.mempalace/agents/. The file specifies the agent's name, its focus domain, its assigned wing in the palace, and the diary format to use. The CLAUDE.md configuration file for your project does not need to list agents individually — it only needs a single line that tells Claude to check for them at runtime:

You have MemPalace agents. Run mempalace_list_agents to discover them.

This single line stays constant regardless of whether you have one agent or fifty. Claude discovers agents dynamically by calling the MCP tool, which means adding a new agent never requires editing CLAUDE.md.

Configuring Your Agents

Create a JSON file for each agent role in ~/.mempalace/agents/:

~/.mempalace/agents/reviewer.json
{
  "name": "reviewer",
  "focus": "code quality, security vulnerabilities, recurring bug patterns",
  "wing": "wing_reviewer",
  "diary_format": "aaak"
}

The focus field is a plain-text description of what the agent pays attention to. The agent reads this at session start so it knows what to look for. The wing field assigns a dedicated palace wing — the agent's memories are isolated from general palace content, which keeps search results clean.

Create one file per domain. There is no limit on agent count:

~/.mempalace/agents/ — example structure
reviewer.json     ← code quality, security, bug patterns
architect.json    ← design decisions, ADRs, system tradeoffs
ops.json          ← deployments, incidents, infrastructure changes
security.json     ← vulnerability findings, compliance issues
performance.json  ← bottlenecks, profiling results, optimisations

What Happens During a Session

When Claude starts a session in a project using MemPalace agents, the sequence is automatic:

  1. Claude reads CLAUDE.md and sees the agent discovery line
  2. Claude calls mempalace_list_agents and receives the list of configured agents
  3. For the current task — say, a code review — Claude calls mempalace_diary_read("reviewer", last_n=10)
  4. The diary returns the reviewer's last 10 entries in AAAK format, giving Claude a concrete record of recent findings
  5. Claude performs the review with that accumulated context available — it knows what patterns the reviewer has seen before
  6. After the review, Claude calls mempalace_diary_write("reviewer", entry) to record the session's findings
  7. The next session begins with that entry in the diary

Diary Entry Format

Diary entries are written in AAAK — compact, pipe-delimited, readable by any LLM. A typical entry captures: identifier, finding type, specific location, contextual note, severity.

AAAK diary entry examples
# Code reviewer findings
PR#42|auth.bypass|missing.middleware.check|pattern:3x.this.quarter|★★★★
PR#51|n+1.query|posts.endpoint|eager.load.fix.applied|★★★
PR#58|hardcoded.secret|config.js:line.34|moved.to.env|★★★★★

# Architect decisions
ADR#12|graphql.adopted|concurrent.write.req+10GB.dataset|2026-01-15|Maya.approved
ADR#15|redis.cache.added|p95.latency.420ms→38ms|load.test.2026-02-20|unanimous

# Ops incidents and deployments
INC#08|db.cpu.spike|missing.index.on.user_id|p0.resolved.30min|2026-02-14
DEPLOY#27|auth-service.v2.3.canary|zero.errors.after.2h|full.rollout.approved

The format is intentionally flexible — the agent writes what is useful to read back later, not what fits a rigid schema. The AAAK pipe-delimiter structure ensures tokens are used efficiently without sacrificing readability.

Example Agent Configurations

Example configurations
# architect.json
{
  "name": "architect",
  "focus": "system design decisions, architectural tradeoffs, ADRs, technical debt",
  "wing": "wing_architect",
  "diary_format": "aaak"
}

# ops.json
{
  "name": "ops",
  "focus": "deployments, incidents, infrastructure changes, on-call patterns",
  "wing": "wing_ops",
  "diary_format": "aaak"
}

Cost Comparison with Letta

FactorMemPalace AgentsLetta
Monthly cost$0$20–200/month
Annual cost$0$240–2,400/year
InfrastructureLocal — nothing to hostCloud — managed for you
Agent count limitNo limitScales with plan
CLAUDE.md complexityOne line, never changesConfiguration-per-agent
Data privacyNever leaves your machineCloud-hosted
Enterprise supportCommunity onlyYes

Practical Tips

  • Keep focus areas narrow and specific. "Security vulnerabilities in authentication and session handling code" will produce more useful diary entries than "security." Specificity helps the agent know what to notice and what to record.
  • Match last_n to the task. Reading last_n=5 is fast and sufficient for routine tasks. Reading last_n=20 provides richer historical context for major decisions — use it when that context will materially affect the outcome.
  • Let agents cross-reference the main palace. An agent can search not only its own wing but the full palace. A security agent investigating an auth issue can call mempalace_search("auth token handling", wing="wing_security") to pull from its own history, or omit the wing filter to search across everything.
  • Review diary entries occasionally. AAAK entries are designed to be read by both the AI and the developer. Reviewing them periodically can surface patterns that neither you nor the AI consciously noticed accumulating.
← Previous
How Milla Jovovich and Ben Sigman Built MemPalace — The Complete Story