ASK KNOX
beta
LESSON 291

Per-Agent Expertise Files: Agents That Learn Between Sessions

Every session starts fresh — unless you build agent-directed memory. Expertise files are what the agent writes about its own work, injected at the next session start.

8 min read·Claude Code Operations

The zero-memory problem is the baseline state of every agent system. An agent that spent three sessions analyzing your trading bot's failure modes — the gate chain that blocked a breakout entry, the signal-computation lag, the bias promotion inversion — starts the next session knowing none of it. You are the only continuity between sessions. The agent's knowledge resets every time.

Human-directed memory systems (a semantic memory layer, MEMORY.md, session notes) partially address this. You tell the system what to remember. The system stores it. The agent retrieves it on demand. But this puts the curation burden on you: you have to notice what's worth remembering, decide to store it, and prompt the agent to retrieve it at the right moment.

Expertise files solve a different problem. The agent decides what to remember. The agent writes it. The agent gets it back at the start of every subsequent session. Zero curation burden on the human.

Human-Directed vs. Agent-Directed Memory

These are complementary systems, not competing ones.

The semantic memory layer (human-directed): Organization-wide, semantically indexed, queryable by topic. Stores anything the human judges worth preserving — session retros, project decisions, trading analysis, system architecture notes. The human decides what goes in. The agent queries it on demand. This is institutional memory.

Expertise files (agent-directed): Agent-private, session-injected, written by the agent about its own work. The agent decides what to record at session end. The file loads automatically at session start. This is personal memory — what this specific agent has learned from its own executions.

The difference matters in practice. The semantic memory layer requires the human to be the memory curator. Expertise files make the agent its own curator. For specialized agents running repeatedly against the same system, expertise files are often more valuable — the agent's specific observations about that system are more targeted than anything the human would think to index.

The File Structure

~/.config/agent/agent-expertise/
  expert-panel.md     ← multi-agent advisory system agent's accumulated observations
  market-analyst.md       ← market-analyst agent's accumulated observations
  content-pipeline.md     ← AI content production pipeline agent's accumulated observations
  trading-bot.md          ← trading-bot analyst agent's accumulated observations

One file per agent persona. The file grows incrementally — each session adds new observations, revises stale ones, removes entries that have been superseded. At any point, the file represents the agent's current best understanding of the system it works on.

The naming convention matters: the file name matches the agent identity used in your orchestration layer. When the system injects context at session start, it reads the file corresponding to the current agent persona.

The System Prompt Injection Block

At session start, before the agent's first task, the expertise file content is injected:

<expertise_file>
{expertise_file_content}
</expertise_file>

Read this before acting. These are your own observations from prior sessions.
Trust them.

The XML wrapper signals to the agent that this is structured context, not conversational history. The instruction "read this before acting" establishes priority — the expertise file is not optional background reading, it is pre-task context that should inform every decision.

"Trust them" is load-bearing. Without it, the agent may treat its own observations as suggestions rather than established facts. With it, the agent treats the expertise file as authoritative — the same way it treats a well-written CLAUDE.md. These are observations from its own prior work. They are more reliable than anything it could reason from first principles.

The Update-Expertise Skill Pattern

The expertise file is written by the agent, at session end, using the update-expertise skill (~75 lines):

The skill does three things:

  1. Read the existing expertise file — load the current state before writing, so the update is incremental
  2. Extract durable, non-obvious observations from the session — what did this session reveal that isn't already captured?
  3. Write the updated file — add new entries, revise entries that need updating, remove entries that are no longer accurate

The skill is invoked as a session-end hook, or explicitly by the agent when it decides the session produced something worth preserving.

The key constraint is what counts as a durable, non-obvious observation. Two examples:

GOOD (durable, non-obvious):

"Win rate above 50% with negative P&L is definitively a risk-reward asymmetry problem, not a signal-quality problem. Do not investigate signals when this pattern appears — investigate position sizing and stop placement."

This observation is specific, actionable, and would take hours of analysis to reconstruct. It tells the agent exactly what to do and what not to do when it encounters this pattern.

PADDING (not durable, not non-obvious):

"I analyzed the trading data and found some patterns worth noting for future reference."

This adds zero information. It records the fact that analysis happened, not what the analysis revealed. An expertise file full of padding is an expertise file that provides no value at session start.

The standard for inclusion: if a new version of the agent, reading only the expertise file and no other context, would behave meaningfully differently because of this entry — it belongs in the file. If not, it's padding.

Compound Learning Over Iterations

The value of expertise files is not session-to-session — it is cumulative across iterations.

By session 1, the expertise file records first impressions: initial system behavior, surface-level patterns, things that surprised the agent.

By session 5, the expertise file reflects real diagnostic patterns: failure modes that have been observed multiple times, causal relationships that have been confirmed, heuristics that the agent has validated.

By session 10, the expertise file is a compressed version of 10 sessions of domain analysis. A fresh agent starting with this file starts with knowledge that would have taken three sessions to reconstruct from scratch. Each session adds new layers. The agent compounds.

This is the design goal: an agent that gets meaningfully smarter about your specific system with each execution, without requiring the human to curate or direct the memory capture.

The practical outcome is agents that skip the exploratory phase. A market-analyst agent without expertise files spends the first 20% of every session re-establishing context: which signals are live, what the current regime classification is, what the known failure modes are. With a mature expertise file, that 20% is reclaimed. The session starts with the agent already oriented.

Implementation

The minimum viable implementation:

  1. Create the expertise file directory: mkdir -p ~/.config/agent/agent-expertise/
  2. Create an empty expertise file for each specialized agent persona
  3. Write the update-expertise skill (~75 lines, invoked at session end)
  4. Add the injection block to each agent's system prompt

The expertise files start empty. They fill up through real work. The compounding starts from the first real session.