Episodic Memory Plugin
The Episodic Memory plugin lets the assistant find and reread **the user's own
earlier conversations**. It works in both directions: two read-only tools the
agent calls when a question points back at earlier work, and — on by default —
a turn-start pass that offers matching conversations before the agent thinks to
ask for them.
It is not the organizational memory, and the two are
independent. Agentic Memory curates team-owned notes, written by a background
model and shared with everyone; Episodic Memory reads nothing but the
conversations of the person typing. Recall writes nothing and makes no model
call. The optional experience distillation
(off by default) does both, for that one person only. A deployment can run
either plugin, both, or neither.
Renamed from Personal Recall. Configs that still say
the old module (…plugins.personal_recall) and classPersonalRecallPlugin
keep working (the loader rewrites them and logs a deprecation warning), users'
stored settings are carried over, and conversations holding
plugin.personal_recall.recalledevents still render. Update the config when
convenient.
What it can see
Scope rides on the same conversation-read checks every other conversation read
in the app already uses, so there is no second policy to keep in sync:
- Only the calling user's own conversations. Never another user's — an id belonging to someone else is refused rather than read.
- Only conversations that still exist. Soft-deleted ones are invisible.
- The current workspace by default. Both the tools and auto-recall stay inside the workspace of the conversation they run in, unless asked to look wider (
workspace: "all"on the tool, All my workspaces in the user's settings).
Ranking comes from the event store's existing FTS5/BM25 index — the same one
behind conversation search in the sidebar. Nothing is copied to disk, no
embeddings are built, and there is no curator and no background job.
The tools
| Tool | Parameters | Returns |
|---|---|---|
recall_conversations | query (required); since (YYYY-MM-DD or a full ISO timestamp); workspace (a workspace id, or all); limit (1–50, default 10) | Matching conversations — title, date, highlighted snippet, and the id to read |
read_conversation | conversation_id (required); turns ("3", "3-5", or omitted for the whole conversation); detail (summary, the default, or full) | The rendered turns of that one conversation |
Every hit is a Markdown link to /c/{id}, the app's own conversation route, so
the tool card in the transcript links straight to what was found — clicking a
result is how a user checks what the assistant just read.
Both tools are token-bounded. read_conversation truncates each turn (tightly
under summary, generously under full) and caps its whole output, so an
unbounded range on a very long conversation cannot flood the context window;
narrow turns when that cap gets in the way.
The agent is told to reach for them when the user refers to earlier work or a
previous decision — "like last time", "as we discussed" — and not to go
fishing otherwise.
Recall at the start of a turn
With auto_recall_enabled (the default), the plugin also pushes: at the start
of a turn it looks for the user's own earlier conversations that the current
message is about, and puts a short linked list just ahead of the query, followed
by a chip in the turn's receipt strip naming what it injected. The note is a **menu, not an
answer** — the agent still has to call read_conversation to use one, and is
told the list was found by keyword and may be irrelevant.
Most turns recall nothing, by design. BM25 is a ranking function, not a
relevance test: it returns its top-N for any query, so a floorless gate would
inject on nearly every turn. The floor here is on the query instead, and it is
derived from the user's own corpus rather than a word list:
- A term must be rare but present. A word in more of the user's conversations than the df ceiling is a stopword for that user and admits nothing; a word nobody has written about can match nothing. No salient term → no recall, which is the common case.
- Each salient term gets its own ranked probe, and the lists are fused, so a conversation two independent rare terms both reach outranks one that a single term found. A single-term hit is admitted only when that term is very rare (at or below
rare_df). - Recency is a prior. The fused score decays with a 60-day half-life toward a floor, so an old but strongly matched conversation is down-weighted rather than erased.
The pass runs once per turn, for the main agent's first step only. It is skipped
for subagents, for scheduled runs (whose "query" is a fixed template that would
recall the same handful of conversations forever), and it never returns the live
conversation, which is in the index and would otherwise match its own query
every turn. A conversation already listed in this chat is not listed again.
What the user controls
Three settings under Settings → Extensions, each with the deployment's own
default filled in:
| Setting | Values | Default |
|---|---|---|
| Recall earlier conversations automatically | on / off | on |
| How eagerly to recall | Focused · Balanced · Broad | auto_recall_default_sensitivity |
| Where to look | This workspace only · All my workspaces | auto_recall_default_scope |
Sensitivity is one dial that moves the whole gate coherently, rather than four
numbers nobody could tune against each other:
| Sensitivity | df ceiling | Lone term admitted at df ≤ | Conversations listed | Token budget |
|---|---|---|---|---|
| Focused — only strong matches | 10 | 2 | 2 | 250 |
| Balanced — the default | 25 | 3 | 3 | 400 |
| Broad — more suggestions, more noise | 60 | 5 | 5 | 700 |
Turning the first setting off leaves the tools in place: the agent can still
pull, it is just not pushed to.
Learning from your conversations (experience distillation)
Off unless the operator sets distillation_enabled: true. Design:
doc/core-dev/design/experience-distillation.md §0b.
- Episodes. A sweeper started once per process (on
onServerReady) checks everysweep_interval_sfor conversations that have been quiet foridle_minutes. It projects each one into an episode, a set of deterministic signals (tool calls and errors, approvals denied, Stop pressed, turn failures, interjections, thumbs, auto-recalled conversations, org-memory cards, rules exposed) kept inexperience.sqlite3. The episode is a rebuildable cache: deleting the conversation deletes it. The first sweep after a start reaches backbackfill_days. It skips scheduled runs, goal workers, review shadows andsystem:owners. A lease row keeps two processes on one data dir from sweeping together. A conversation is also idle as soon as its owner starts a turn in another one and it has no turn running (a turn paused on an approval counts as running): that turn start (onInputReceived) wakes the sweeperswitch_wake_delay_slater instead of at the next tick, with every wake in between folded into that one sweep. - The distiller. For episodes that pass the trigger, one model call (
distill_model_role, falling back to the agent model) reads the conversation. It returns a one-line summary, friction labels (correction, redirect, frustration, preference, praise, each with a quote checked against what the user actually wrote) and at most two new lesson proposals or evidence for existing claims. Proposals are kept on the episode, not made claims (see 6). A proposal the model markskind: fact— a path, a repo convention, what a tool reads — is not kept at all: it is emitted as the hookonExperienceFact, which org memory (agenticmemory), when present, records as a curator hint. The trigger isdistill_trigger: friction(a structural sign something went wrong, or ≥ 3 user turns),all, oroff— no background model calls at all: episodes are still projected, but nothing is distilled, consolidated or checked, no facts are routed out, and with no friction labels the sweep's corrections never reachturn_reactions/rule_outcomes(thumbs and Stops still do). It runs at mostdistill_daily_captimes per user per day and 5 per sweep, newest conversations first. - Claims and rules. Claims are Markdown files under
<data dir>/experience/<user>/claims/. The user sees them in Settings → Extensions → Episodic Memory ("What I've noticed") and can confirm, dismiss or make a rule of each one. A rule is the user's own text, saved under…/rules/withauthority: user_approvedand an expiry (rule_expiry_days). It is injected as a prefix context note ([Learned rules]) for the main agent in the rule's workspace, or everywhere, and every (rule, conversation, turn) it reaches is logged. Nothing the distiller writes changes behaviour until the user adopts it.
- Learning from a reaction (immediate path, §0c). With
immediate_learningon (the default once distillation is on), a thumbs-down — theuser_feedbackplugin'sonUserFeedbackhook — or Learn from this in an answer's action row opens a learning card in the conversation at once ("Noted — I'll look at what went wrong here"). One focused model call reads that answer's turn ±3 turns, the first two turns, the thumbs-down comment, the user's rules and related claims, and proposes one rule. The card shows it editable, with a scope switch and the user's own words as evidence: Make it a rule (applies from the next turn), Keep as a note (a candidate claim) or Not a lesson. When no lesson is found the user can type one. Either way the claim isuser_explicit. One card per answer; at mostimmediate_daily_capfocused calls per user per day, counted apart fromdistill_daily_cap. A thumbs-up opens no card and is kept as praise on its turn. The card is web-only; without it the lesson is kept as a candidate claim.
The user's second Stop within three turns (onTurnInterrupted with
cancelled_by: user; a timeout or shutdown does not count) opens the card
as an offer: "Want me to learn from this?" Yes runs the same focused
call (and only then takes a slot of the daily cap); No dismisses it.
One offer per run of Stops.
A rule that did not hold. When any of these reactions (not a
thumbs-up) lands on a turn where an adopted rule was injected, the card
records those rules and the focused call is told they were in effect. It
judges the answer against each: only when it says the answer did not
follow one (an explicit rule_not_held verdict — never inferred from a
proposal that restates the rule, or from a single rule being in effect)
does the same card say the rule did not hold and offer to **Update the
rule** (the editable text rewords it in place; the scope switch rescopes
it) or Retire the rule. A proposal that restates a rule the answer
followed reads "Strengthen rule '…'?" instead.
- A preference the user states (
propose_rule). On the same switch, the main agent of an attended conversation (not subagents, scheduled or webhook-fired runs, or internal sessions) gets apropose_ruletool{text, quote, scope, replaces?}. When the user says how the assistant should work from now on, the agent calls it and carries on; the quote must be verbatim in the current user message. No model call: the card opens at once with the rule pre-filled, or as "Strengthen rule '…'?" when it restates or contradicts a live rule — the onereplacesnames (the injected rules note shows each rule's id for this), else the closest by wording (case, inflection and asides ignored). One stated card per user message (apart from a reaction card on the same answer), and at mostimmediate_daily_capstated cards a day, counted apart from the focused calls. With the per-user setting Adopt rules I state without asking (auto_adopt_stated_rules, default off) the rule is written at once and the card shows it with Undo, which retires it (learning_cards.actionauto, thenundone); replacing an existing rule still waits for the click. Without the web card the rule is kept as auser_explicitcandidate (or written, with auto-adopt on).
- Daily consolidation and the evidence check (§0c.4–0c.5). Once a day per user, one model call groups pending proposals that state the same lesson; a group makes or supports a claim only when it spans at least two conversations, and a proposal alone for 30 days expires. Before anything is written, one more small call asks, for each proposal a group would use and each contradiction, whether that turn's user text is about the statement at all (yes / no / contradicts):
nodrops it,contradictsflips support into a contradiction (and the reverse), and a missing answer leaves it for tomorrow. If that call fails, nothing about proposals is applied that day. Learning-card proposals skip it — the user decided on the card. The panel's main list shows claims the user stated first, then recurring ones by conversations × recency, at most 7; recurring ones past the cap fold under "More that came up again", the rest under "Seen once, or less often".
The per-user setting Learn from my conversations (default on) stops
distilling, learning cards and rule injection for that user; a setting that
cannot be read counts as off.
How to learn (learning_mode: both, the default; immediate; or
background) picks the paths that run for the user. immediate keeps the
cards and leaves that user out of the sweep's distill and consolidation
(their conversations are still projected). background opens no cards:
thumbs-down, a repeated Stop and "Learn from this" make none (the button
hides itself, asking learning/available), and propose_rule is not
offered — but thumbs and Stops are still kept in turn_reactions for
rule_outcomes. The operator only narrows: the effective mode is the user's
choice intersected with what immediate_learning and distill_trigger
allow, so a user who chose the one path the operator turned off learns
nothing new (the panel says so). The setting is offered only while both
paths are allowed. An unreadable setting means no path runs.
Data it produces, for judging whether any of this helps:
- episodes, with signals, structural outcomes, friction labels and summaries;
claim_verdicts: every confirm, dismiss, reopen and adopt, with a time;rule_exposures;distill_log: each run's status and duration;learning_cards: trigger, state reached, the user's answer (adopt, note, dismiss, own text, auto / undone, or ignored), seconds to answer, and the edit distance between the suggested and the adopted rule;turn_reactions: per turn, a thumbs-up (praise), a thumbs-down, the user's Stop, and the sweep's corrections (a correction, redirect or frustration labelled on the next user message, kept on the answer it corrects);evidence_checks: each verdict of the consolidation's evidence check (proposal, conversation, turns, the statement, verdict, the model's raw answer);rule_outcomes: a view overrule_exposuresandturn_reactions— for every turn a rule was injected into, whether it was disliked, stopped, corrected or praised. The rules list shows the counts; deleting a conversation removes its rows with the two tables underneath.
Export in the panel downloads all of it for the signed-in user.
Routes
Mounted at /ui/plugins/episodic_memory/experience/, always scoped to the
caller. Another user's id is a 404, like an unknown one.
| Method | Path | Purpose |
|---|---|---|
| GET | summary | Counts, whether it is on for the operator and the user, the effective learning_mode (null when no path runs), last sweep |
| GET | claims?status= | Claims with linked evidence (deleted conversations drop out) |
| POST | claims/{id}/verdict | `{verdict: confirm \ |
| POST | claims/{id}/adopt | `{text, scope: workspace \ |
| GET | rules | Rules with exposure counts and outcomes: {exposed, thumbs_down, stopped, corrected, praised} |
| PATCH | rules/{id} | {text?, status?: retired, renew_days?} |
| GET | episodes?limit= | Recent episodes |
| POST | run | Sweep and distill now for the caller (bounded) |
| GET | export | Everything above as a JSON download |
| POST | learning | {conversation_id, turn_id?, assistant_message_id?} → {enabled, card} ("Learn from this") |
| GET | learning/available | {available}: whether the caller gets learning cards ("Learn from this" hides when false) |
| GET | learning/cards/{id} | A learning card (one left working by a restart comes back expired) |
| POST | learning/cards/{id}/adopt | {text, scope} → card done with a rule |
| POST | learning/cards/{id}/note | {text, scope} → card done with a candidate claim |
| POST | learning/cards/{id}/dismiss | → card dismissed |
| POST | learning/cards/{id}/undo | → card undone: retires an auto-adopted stated rule |
| POST | learning/cards/{id}/accept | Yes on a repeated-Stop offer → card noted; the focused call starts |
| POST | learning/cards/{id}/decline | No on an offer → card dismissed (action decline) |
| POST | learning/cards/{id}/retire | → card done: retires the rule that did not hold (rule_at_stake) |
With distillation off, summary says so and the lists are empty, which is
what the panel renders as its off state.
Configuration
Enabled in the default shipped config, which carries this block:
plugins:
- module: codumentor.plugins.episodic_memory
class: EpisodicMemoryPlugin
args:
enabled: true
auto_recall_enabled: true
auto_recall_default_sensitivity: balanced
auto_recall_default_scope: workspace
| Parameter | Type | Default | Description |
|---|---|---|---|
enabled | bool | true | Whether the plugin is active. |
target_agents | kind / role / list | all | Which agents get the recall tools. Both are reads, so there is no separate write tier. |
auto_recall_enabled | bool | true | Offer turn-start auto-recall at all. false removes it for every user here and hides its settings; the tools are unaffected. |
auto_recall_default_sensitivity | focused \ | balanced \ | broad |
auto_recall_default_scope | workspace \ | everywhere | workspace |
distillation_enabled | bool | false | Run experience distillation (above). Off, nothing of it runs and the panel says so. |
distill_trigger | friction \ | all \ | off |
distill_model_role | string \ | null | experience_distiller |
distill_daily_cap | int ≥ 0 | 40 | Most distiller runs per user per day. |
idle_minutes | float | 20 | How long a conversation must be quiet before it becomes an episode. |
sweep_interval_s | float ≥ 10 | 300 | Seconds between sweeps. |
switch_wake_delay_s | float ≥ 0 | 30 | After a user starts a turn in another conversation, wake the sweeper this much later (wakes in between coalesce). |
backfill_days | float ≥ 0 | 30 | How far back the first sweep after a start reaches. |
immediate_learning | bool | true | With distillation on, open a learning card on a thumbs-down, "Learn from this" or a repeated Stop (as an offer), and offer propose_rule. Off removes the immediate choice from learning_mode; thumbs and Stops are still recorded. |
immediate_daily_cap | int ≥ 0 | 20 | Most focused distills per user per day, apart from distill_daily_cap. |
rule_expiry_days | int ≥ 1 | 90 | Lifetime of an adopted rule before it must be renewed. |
The rest are pins, not defaults. Each resolves as *shipped preset ←
operator ← user*, and setting one overrides that parameter for every
sensitivity row in the deployment while the user's choice still moves
everything else. Leave them unset — the default — to follow the user.
| Parameter | Type | Default | Pins |
|---|---|---|---|
auto_recall_df_ceiling | int ≥ 1 | unset | How common a term may be and still count as distinctive. |
auto_recall_rare_df | int ≥ 1 | unset | How rare a term must be to admit its hits uncorroborated. |
auto_recall_max_hits | int 1–10 | unset | How many conversations one note may list. |
auto_recall_token_budget | int ≥ 50 | unset | Ceiling on the injected note, in estimated tokens. |
auto_recall_recency_half_life_days | float > 0 | 60 | Fused-score half-life. Not part of the sensitivity rows: it describes the corpus, not an appetite. |
A deployment whose corpus it actually knows something about is the reason pins
exist — a term appearing in 40 conversations may genuinely be distinctive here.
Everywhere else, the preset rows are better than a hand-picked combination.
Notes
- A pin is deployment-wide. It overrides the chosen row for every user, so a pinned
auto_recall_max_hits: 5makes Focused list five conversations too. Pin the one parameter you have evidence about, not the set. - How often does it abstain?
capabilities()["episodic_memory"]carries per-instance counters — attempts, injections, and abstentions by reason (no_salient_terms,uncorroborated,no_hits,all_seen, …). That ratio is the number to watch: an auto-recall that fires on nearly every turn is misconfigured, not eager. - Recall stores nothing. No tables, no Markdown copies, no embeddings — only the per-user settings row. What experience distillation stores is listed in its section above.
- The web bundle is only the Settings panel. The tool calls render on the generic tool card and the recall card on the UI's generic plugin renderer;
ui/plugins/episodic_memory/carriesx-episodic-memory-experience. - For plugin authors: an injected recall emits the conversation event
plugin.episodic_memory.recalled, carrying the listed conversations and their links. - Ships in Community and Full editions.
- Design and phasing:
doc/core-dev/design/experience-distillation.md§4 (Phase 0 the tools, Phase 0.5 auto-recall) and §0b (distillation).
Web experience management
Settings → Extensions → Episodic Memory exposes the deployment-published preference
schema above a compact learning overview. Recall controls remain available when
experience distillation is unavailable, provided the operator permits recall.
Automatic recall, explicit conversation search, and learning/adopted rules are
separate controls; turning automatic recall off retains sensitivity and scope.
Preferences autosave using the host's changed-key write contract (failures remain
locally saved and are reported by the host), not a second widget save mechanism.
Manage experiences opens /plugins/episodic_memory/experiences:
- Noticed preserves server ranking and main/more/seen-once distinctions; dismissed items can be explicitly selected and reopened. Confirmation alone does not make an observation a runtime rule.
- Your rules defaults to active rules; expired/retired filters retain access to previous rules and permitted renewal actions. Editing uses its own Save/Cancel.
- Recent conversations loads ten on demand, with increasing requests up to the existing 200-item cap. This is recent history, not all conversation history.
Search, scope and status filters run locally over fully fetched claims/rules;
20 matching rows at a time bounds visible content, not network or memory use.
Details disclose evidence and actions. Adoption, dismissal, reopening, editing,
90-day renewal, retirement confirmation, Check now and JSON export remain
available. The URL hash retains view/filter/page state for refresh and Back;
unsaved editor drafts survive local view/filter changes but not a page reload.
The backend continues to scope all experience routes to the signed-in user.
The layout opt-in is settings_widget.show_schema: true; absent/false retains
the host's replacement-only custom-widget behavior. Backend and bundle manifests
both register the manager page and its x-episodic-memory-manager element.