Codumentor logo Codumentor Enterprise

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 class PersonalRecallPlugin
keep working (the loader rewrites them and logs a deprecation warning), users'
stored settings are carried over, and conversations holding
plugin.personal_recall.recalled events 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:

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

ToolParametersReturns
recall_conversationsquery (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_conversationconversation_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:

  1. 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.
  2. 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).
  3. 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:

SettingValuesDefault
Recall earlier conversations automaticallyon / offon
How eagerly to recallFocused · Balanced · Broadauto_recall_default_sensitivity
Where to lookThis workspace only · All my workspacesauto_recall_default_scope

Sensitivity is one dial that moves the whole gate coherently, rather than four
numbers nobody could tune against each other:

Sensitivitydf ceilingLone term admitted at df ≤Conversations listedToken budget
Focused — only strong matches1022250
Balanced — the default2533400
Broad — more suggestions, more noise6055700

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.

  1. Episodes. A sweeper started once per process (on onServerReady) checks every sweep_interval_s for conversations that have been quiet for idle_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 in experience.sqlite3. The episode is a rebuildable cache: deleting the conversation deletes it. The first sweep after a start reaches back backfill_days. It skips scheduled runs, goal workers, review shadows and system: 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 sweeper switch_wake_delay_s later instead of at the next tick, with every wake in between folded into that one sweep.
  2. 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 marks kind: fact — a path, a repo convention, what a tool reads — is not kept at all: it is emitted as the hook onExperienceFact, which org memory (agenticmemory), when present, records as a curator hint. The trigger is distill_trigger: friction (a structural sign something went wrong, or ≥ 3 user turns), all, or off — 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 reach turn_reactions / rule_outcomes (thumbs and Stops still do). It runs at most distill_daily_cap times per user per day and 5 per sweep, newest conversations first.
  3. 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/ with authority: user_approved and 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.
  1. Learning from a reaction (immediate path, §0c). With immediate_learning on (the default once distillation is on), a thumbs-down — the user_feedback plugin's onUserFeedback hook — 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 is user_explicit. One card per answer; at most immediate_daily_cap focused calls per user per day, counted apart from distill_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.

  1. 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 a propose_rule tool {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 one replaces names (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 most immediate_daily_cap stated 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.action auto, then undone); replacing an existing rule still waits for the click. Without the web card the rule is kept as a user_explicit candidate (or written, with auto-adopt on).
  1. 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): no drops it, contradicts flips 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:

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.

MethodPathPurpose
GETsummaryCounts, whether it is on for the operator and the user, the effective learning_mode (null when no path runs), last sweep
GETclaims?status=Claims with linked evidence (deleted conversations drop out)
POSTclaims/{id}/verdict`{verdict: confirm \
POSTclaims/{id}/adopt`{text, scope: workspace \
GETrulesRules with exposure counts and outcomes: {exposed, thumbs_down, stopped, corrected, praised}
PATCHrules/{id}{text?, status?: retired, renew_days?}
GETepisodes?limit=Recent episodes
POSTrunSweep and distill now for the caller (bounded)
GETexportEverything above as a JSON download
POSTlearning{conversation_id, turn_id?, assistant_message_id?} → {enabled, card} ("Learn from this")
GETlearning/available{available}: whether the caller gets learning cards ("Learn from this" hides when false)
GETlearning/cards/{id}A learning card (one left working by a restart comes back expired)
POSTlearning/cards/{id}/adopt{text, scope} → card done with a rule
POSTlearning/cards/{id}/note{text, scope} → card done with a candidate claim
POSTlearning/cards/{id}/dismiss→ card dismissed
POSTlearning/cards/{id}/undo→ card undone: retires an auto-adopted stated rule
POSTlearning/cards/{id}/acceptYes on a repeated-Stop offer → card noted; the focused call starts
POSTlearning/cards/{id}/declineNo on an offer → card dismissed (action decline)
POSTlearning/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
ParameterTypeDefaultDescription
enabledbooltrueWhether the plugin is active.
target_agentskind / role / listallWhich agents get the recall tools. Both are reads, so there is no separate write tier.
auto_recall_enabledbooltrueOffer turn-start auto-recall at all. false removes it for every user here and hides its settings; the tools are unaffected.
auto_recall_default_sensitivityfocused \balanced \broad
auto_recall_default_scopeworkspace \everywhereworkspace
distillation_enabledboolfalseRun experience distillation (above). Off, nothing of it runs and the panel says so.
distill_triggerfriction \all \off
distill_model_rolestring \nullexperience_distiller
distill_daily_capint ≥ 040Most distiller runs per user per day.
idle_minutesfloat20How long a conversation must be quiet before it becomes an episode.
sweep_interval_sfloat ≥ 10300Seconds between sweeps.
switch_wake_delay_sfloat ≥ 030After a user starts a turn in another conversation, wake the sweeper this much later (wakes in between coalesce).
backfill_daysfloat ≥ 030How far back the first sweep after a start reaches.
immediate_learningbooltrueWith 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_capint ≥ 020Most focused distills per user per day, apart from distill_daily_cap.
rule_expiry_daysint ≥ 190Lifetime 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.

ParameterTypeDefaultPins
auto_recall_df_ceilingint ≥ 1unsetHow common a term may be and still count as distinctive.
auto_recall_rare_dfint ≥ 1unsetHow rare a term must be to admit its hits uncorroborated.
auto_recall_max_hitsint 1–10unsetHow many conversations one note may list.
auto_recall_token_budgetint ≥ 50unsetCeiling on the injected note, in estimated tokens.
auto_recall_recency_half_life_daysfloat > 060Fused-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

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:

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.