Agent Memory & Context
How do you make agent memory visible and editable?
The quick read · Pattern 06
The 60-second version
Let people inspect the context that shapes an agent’s answers. Separate this session’s information, explicitly saved preferences and inferred patterns so a mistaken memory can be found and corrected.
- Show each memory’s source, scope and last confirmation.
- Cite the entries used in a response and link back to their controls.
- Offer correction, deletion and a fresh response without the disputed entry.
Watch for: An inference is a hypothesis about a person, not a fact. Explain deletion’s scope and any remaining copies instead of promising that one control erases every trace.

The Problem
Agents that remember things about you are powerful. Agents that remember things about you that you can't see, can't correct, and can't delete are dangerous. The longer you use an AI agent, the more context it accumulates — your preferences, your past decisions, corrections you've made, patterns it's inferred from your behaviour. That accumulated context shapes every recommendation, every default, every prioritisation the agent makes. And when that context is wrong — stale, misinterpreted, or just no longer true — the agent starts making bizarre decisions and the user has no way to diagnose why.
Persistent memory can make an agent more useful across sessions. The design challenge is making it possible to inspect, correct and remove what the agent remembers.
The Anti-Pattern
The Invisible Memory Problem. The agent personalises a result without showing which saved information influenced it.
The All-or-Nothing Context Switch. The only choice is to load an entire project’s memory or use none of it. The user cannot inspect or select relevant pieces.
The Stale Preference Lock-In. An old preference keeps shaping results even after the user’s needs change.
The Frankenstein Context Problem. An assistant pulls from many documents but does not show which ones informed its recommendation.
The common failure: treating agent memory as an implementation detail rather than a user-facing feature that demands the same design rigour as any other data the user owns.
The Pattern
The Three Memory Types
Every agent memory system contains three distinct types. Each needs different visibility, different edit affordances, and different lifecycle management:
| Type | What It Is | Source | Lifecycle | User Control |
|---|---|---|---|---|
| Session Memory | Context from the current conversation or task | Explicit: what the user said and did in this session | Dies when session ends (or is explicitly promoted) | View inline; implicitly controlled by conversation flow |
| Persistent Memory | Facts, preferences, and context that survive across sessions | Explicit saves, user corrections, declared preferences | Indefinite until edited or deleted | Full CRUD: view, edit, delete, export |
| Learned Memory | Behavioural patterns inferred from user actions over time | Implicit: the system observed you doing X repeatedly | Decays over time; refreshed by continued behaviour | View, confirm, reject, adjust confidence |
The critical design principle: Users must be able to distinguish which type of memory influenced a decision. "You asked me to use TypeScript in this conversation" (session) is fundamentally different from "You've told me you prefer TypeScript" (persistent) which is fundamentally different from "I've noticed you always convert my Python suggestions to TypeScript" (learned). The trust calculus is different for each.
State 1: The Memory Inspector
The memory inspector is the primary UI surface. It's not a settings page buried four levels deep. It's accessible from any agent interaction via a persistent affordance — a sidebar panel, a dedicated tab, or a memory icon in the agent header.
-
Session · this conversation
Working on pattern 6; Markdown format; first-person practitioner tone.
-
Saved preferences · user stated
- Dark mode · personal projects
- Source: conversation, 14 October 2026
- TypeScript / Next.js / Tailwind
- Source: stated preference
- Company X · stale
- Last confirmed 12 August 2026; review before reuse
- Edit saved entry
- Delete saved entry
-
Learned patterns · inferred
- Error handling in code examples
- 12 interactions; illustrative inference score 84%
- Concise responses
- 5 interactions; illustrative inference score 67%
- Confirm inference
- Reject inference
- Adjust scope
Key design decisions in this wireframe:
- Labelled by type and status. Session context, user-stated preferences and inferred patterns have separate sections. Stale entries carry an explicit review label. Colour may reinforce these distinctions, but the words must carry the meaning.
- Source attribution on every entry. Not just "User prefers dark mode" but where this memory came from and when. This is the Traceability pillar from the Accountability Lab applied directly to memory.
- Staleness indicators. A persistent memory that hasn't been referenced or confirmed in 90 days gets a visual flag. This isn't automatic deletion — it's a prompt for the user to review.
- Confidence scores on learned patterns. The agent isn't stating facts about you; it's stating hypotheses with evidence. "Based on 12 interactions" tells you this is a well-supported inference, not a guess from one data point.
- Three-action learned memory controls. Confirm (locks it in as persistent), Reject (deletes the inference), or Adjust (edit what the agent inferred — "Not concise always, just for code reviews").
State 2: Memory Citations in Agent Responses
When the agent uses a memory to shape its response, it must cite it. This is non-negotiable. The citation is the mechanism that closes the diagnosis loop — when the agent does something unexpected, the user can trace it back to the specific memory entry.
-
Agent response
Here is the component in TypeScript with Tailwind styling and error handling.
-
Context used
- Stated stack
- TypeScript, Next.js, Tailwind
- Inferred pattern
- Usually requests error handling
- Scoped preference
- Dark mode for personal projects
- Inspect cited memory entries
The citation format matters:
- Collapsed by default for experienced users who trust their memory profile.
- Expanded by default for the first 30 days, or when a learned memory is used for the first time.
- Always expandable via a "Context used" disclosure triangle.
- Directly actionable — each cited memory links to its inspector entry. One click to edit or delete. If the user sees "Dark mode preference" cited and thinks "That's wrong for this project," the path from diagnosis to correction is a single click.
State 3: Memory Correction Flow
When the user edits or deletes a memory, the agent must acknowledge the change and, critically, offer to re-run the most recent action without the corrected memory.
-
Remove memory?
“Prefers dark mode for all projects” was used in the last three interactions. Removing it may change future recommendations.
- Edit instead
- Prefers dark mode for personal projects
- Delete entry
- Stop using this saved preference
- Regenerate response
- Try the last answer without this entry
- Cancel
- Confirm chosen change
The "Delete and re-generate" option is crucial. It lets users see the impact of the memory on behaviour, building understanding of how memory works and trust in the correction mechanism.
State 4: Cold Start vs. Warm Context
New users face the cold start problem: the agent knows nothing and delivers generic behaviour. Long-term users face the opposite: the agent knows too much, some of it wrong.
Cold Start Onboarding (first session):
-
Set up your context
Tell the agent a preference, review an import, choose a template, or start with no saved context.
- Start with a blank slate
- Set preferences
- Review an import
Key design principle: The agent should ask before assuming. In the first five interactions, every inferred preference should be surfaced for confirmation: "I noticed you reformatted to bullet points twice. Should I default to bullets? [Yes, always] [Yes, for this project] [No, coincidence]." After calibration, the agent shifts to background learning with periodic review prompts.
State 5: Memory Decay
Not all memories age equally. The system needs a decay model:
| Memory Type | Default Decay | Behaviour |
|---|---|---|
| Session | Ends with session | Optionally promote to persistent via "Remember this" |
| Persistent (stated) | No automatic decay | Staleness flag at 90 days unreferenced; user reviews |
| Persistent (corrected) | No automatic decay | Corrections are high-signal; never auto-expire |
| Learned (high confidence) | De-weight 10% per month if unreinforced | Drop below 40% confidence → prompt user to confirm or discard |
| Learned (low confidence) | De-weight 25% per month if unreinforced | Drop below 40% → auto-archive with notification |
The decay notification:
"🧠 I noticed I haven't used some of my learned patterns about you in a while. 3 patterns are fading — want to review them? [Review] [Let them fade]"
Decay is not deletion. Decayed memories move to an archive. Users should be able to restore them — people change jobs then change back, abandon frameworks then return. Memory systems need an undo for the undo.
Design in practice
Imagine a research assistant that remembers a preferred market. Its memory panel shows the source and scope of that preference. When the user changes market, the agent shows the proposed edit, applies it after confirmation, and makes the revised entry visible.
Implementation Notes
Data Model (core fields):
MemoryEntry {
id: string
type: "session" | "persistent" | "learned"
content: string
source: { type: "stated"|"inferred"|"corrected"|"imported",
conversation_id?: string, timestamp: datetime,
evidence?: string[] }
confidence: float // 0.0-1.0; always 1.0 for stated
last_referenced: datetime
decay_rate: float // Monthly decay multiplier
status: "active" | "stale" | "archived" | "deleted"
}
API Surface (minimum viable):
GET /memory— List active memories, filterable by type and stalenessPOST /memory— Create persistent memoryPATCH /memory/:id— Edit content or statusDELETE /memory/:id— Soft-delete to archiveGET /memory/:id/usage— Which responses referenced this memoryPOST /memory/promote— Promote session observation to persistentPOST /memory/export/POST /memory/import— Data portability
Event Interface:
memory.created— Fires when a new memory is added (any source)memory.cited— Fires when a memory influences a response (for analytics)memory.decayed— Fires when confidence drops below thresholdmemory.correction— Fires when user edits or deletes a memory (training signal)
Edge Cases:
- Conflicting memories: User says "I prefer Python" but has 30 TypeScript sessions. Surface the conflict explicitly: "You've told me you prefer Python, but I've noticed you mostly use TypeScript. Which should I prioritise?" Never silently resolve a contradiction.
- Privacy-sensitive memories: Support a "sensitive" flag that excludes entries from export and applies stricter access controls.
- Multi-agent memory sharing: In systems like the Hermes 9-bot roster, memory should be shared by default (code preferences apply whether talking to the research bot or the coding bot), with per-agent overrides.
- Memory size limits: When the store outgrows prompt capacity, implement relevance retrieval — not all memories go into every interaction. The "Context used" citation tells the user which were retrieved.
When to Use / When NOT to Use
| Scenario | Use This Pattern | Notes |
|---|---|---|
| Agent with same user across multiple sessions | Yes — full pattern | Full inspector + citations + decay |
| Enterprise agent with compliance requirements | Yes — with audit extensions | Immutable memory log, restrict deletion of compliance entries |
| One-shot agent (single task, no return visits) | No | Session memory only |
| Agent with structured user profile (CRM, HR) | Partial | Source system IS the memory; add citations but edit via source |
| Consumer chatbot, casual interactions | Partial | Lightweight preferences + easy "forget everything" |
| Multi-user shared team assistant | Yes — with scoping | Private per-user memory; shared team context managed collectively |
| Sensitive data (medical, legal, financial) | Yes — enhanced controls | Explicit consent, retention policies, right-to-erasure, Accountability Lab Traceability |
When NOT to use this pattern:
- Stateless API agents with no user continuity.
- Agents where "memory" is actually a database query (e.g., a customer service bot looking up order history) — that's data retrieval, not agent memory. The edit path is the source system.
- Situations where retaining information introduces privacy or safety risks. If durable memory offers little benefit, limit the data to the current task.
This pattern is part of the AX Pattern Library — interaction patterns for agent experiences, drawn from building Hermes Agent's 9-bot delegation roster and the Accountability Lab framework. Memory without visibility is surveillance. Memory with visibility is personalisation.