Extraction from transcripts
Extract durable facts from agent transcripts, keep links to their source turns, and apply the namespace’s write policies.
memory.set_from_messages takes a transcript and the server decides what in it is
durable. Use it when the caller cannot decide inline what to save: raw API consumers,
batch importers, and coding-agent hooks that capture a session at its end. A caller that
already knows the fact should call memory.set (writing). Extraction
writes through memory.bulk_set, so every extracted fact meets the same blacklist, lock,
pin and conflict checks. Configure a real LLM provider for meaningful extraction. The
stock fake provider is a deterministic development/test client that can synthesize
facts.
What a call does
-
The turns are stored as evidence first (
loom.memory_evidence), so a fact can be traced to its sentence (memory.evidence) and the raw wording stays searchable (memory.recall). -
The default pipeline runs these steps in order:
Step What it does loom.fetch_namespace_categoriesLoads the namespace’s categories, so extracted tags use that taxonomy. loom.fetch_existing_memoriesShows the extractor the nearest existing memories, so it does not repeat them. loom.llm_extractThe extraction call; long transcripts are split into segments, one call each. loom.drop_recall_echoesDrops facts that restate a memory the session was served ( recalled_keys) or named.loom.drop_session_echoesDrops facts that restate what the session’s own Loom calls wrote, asked or got ( session_values).loom.drop_activity_narrationDrops narration of tool activity with no outcome (“User read lines 1-1000 of X”). loom.drop_non_durableCoding captures only: drops status snapshots, housekeeping, first-person plans, in-batch repeats. loom.verify_durableCoding captures only: a model pass drops non-durable facts and facts already stored. Fails open. loom.hash_dedupDrops facts whose canonical content hash is already stored. loom.bulk_writeWrites through memory.bulk_set, with verdicts and one hash-only audit row per write. -
The handler then links each memory to its evidence, drafts a session digest and projects entities.
The conversation is also kept as verbatim chunks, which search returns as chunk hits. A
chunk or digest whose text reads as high (a pasted API key, a password= assignment,
a card number, an SSN or a stated PIN) is stored as written but never embedded, so search
and memory.ask never serve it; memory.get on its chunk: key does, with a
memory.sensitive_read audit row (sensitivity).
pipeline_steps reorders or skips steps, or names an in-process step an operator
registered (at most 16; an HTTP hook.* step is refused). See the
extraction pipeline guide.
Keys are minted from a fact’s subject and attribute, never its value. A later
session that states the same attribute lands on the same key and revises the row. When
the user asks to forget something, the matching rows are retired and named in
forgotten / forgotten_keys (a window’s latest 50 requests are matched by content).
A stored fact said again by a later coding capture is dropped when the verifier
finds the memory that states it. loom.verify_durable reads the stored memories nearest
each remaining fact: the writer’s agent and user, any session, the capture’s repository
(its repo: tag, or its project: tag when it has none; a capture with neither is not
narrowed), never a high row, and only served rows with no valid_to and no expiry. Only
the first verifier model is sent them. A fact that it lists as stated in full by one of
its own is dropped, and that memory gets one evidence usage event instead. A listed fact
stays when an earlier fact the step keeps has its key, so the write sees both statements
of that key. Every fact the step keeps goes on to the
write-time conflict check.
A fact the extractor gave a valid_at, a valid_to or a foresight window is compared
with no stored memory, and an append_only namespace skips this read.
Coding captures are requests whose extra_tags carry source:claude-code,
source:codex or source:cursor (the plugins tag every capture), or a trajectory replay
from the observe plane. Only these run loom.drop_non_durable and loom.verify_durable.
The rules in server/memory/domain/durable_facts.py match sentence shape, not topic words: what
a release changed is kept; whether its CI was green at the time is dropped.
A plugin’s session capture (a source: tag) is extracted with a prompt of its own, at
every capture size. It holds no conversation rule or example, and is under 9,000
characters, less than a sixth of the conversation prompt for an input of either size,
because most captures hold nothing to keep and the prompt is then what the call costs. A
session that made a tested change is sent about 1,200 characters more (the
fix record rules). What the user states that holds beyond the session is kept: a standing rule, a
preference, a decision, a fact about their setup. What the user asks for the task alone is
not. Its schema asks for the fields a coding fact uses and for the end of a state the user
bounds (valid_to, foresight), so a freeze “until Friday” stops being served after that
day. The prompt asks for no valid_at, temporal_confidence, occurrence record or
question_topic on a session capture’s fact. The row takes its valid_at from the time
of the latest turn the fact cites, when the capture’s messages carry a timestamp and the
fact’s temporal_anchor names no other day or time of day; else from the call’s own
valid_at; else from the fact’s temporal_anchor when that is not in the future; else
from the observation date. From the work, only knowledge about the codebase that a later
session in the repository can reuse without reading the code again is kept:
- how a behaviour is reached across definitions or files, as one claim for the whole path;
- a relation between definitions that reading one of them does not show;
- an invariant, constraint or pitfall with its reason, and which test constrains a definition;
- the cause of a bug in the code as it was before the session’s edits.
The rules ask for each claim to name its definitions in backticks beside their file paths,
without line numbers: those names and paths are what the
code link pass links a memory by. What the
session itself edited or added is left out, but for its one fix record:
until it is committed it exists in one working
tree, and the commit history records it afterwards. The task, test results and anything
one lookup answers (where a single name is defined, what one function’s text says) are
left out too. An empty fact list from a session capture is an answer: the extractor is not
asked again, and the coverage sweep reads the capture only when the namespace or the call
turns it on. loom.verify_durable judges what remains by the same rules. A trajectory
replay is extracted under its own instructions and verified without the codebase rules.
The model calls of a session capture are these:
- one extraction call for each window (a capture within
LOOM_MEMORY_EXTRACT_SIZE_SEGMENT_MESSAGESandLOOM_MEMORY_EXTRACT_SIZE_SEGMENT_CHARSis one window), asked once more when the provider cut the reply, when it does not parse, or when every fact object in it was discarded; - one relation backfill call after an extraction whose reply left a fact with two or more entities and no relation;
- one
loom.verify_durablecall per verify model, when the extraction left a fact other than the fix record; - the coverage sweep and the extraction judge, when the namespace or the call turns them on.
LOOM_MEMORY_EXTRACT_SESSION_CAPTURES=false turns all of them off: a session capture
then makes no model call, the lowest-cost mode. Nothing the user stated (a rule, a
preference, a decision) and nothing the session worked out (the cause of a bug, a
pitfall) is extracted from it. It leaves what needs no model: a
fix record stated from the client’s names, a user fact an
assistant turn states as its premise, what its turns ask to forget, and its turns as
evidence and verbatim chunks. An embedding is not one of these calls: the capture’s turns
are still embedded to read the memories near them, and what it stores is embedded as it
is written. Other captures (a conversation, a trajectory replay) are extracted as before.
The fix record
A session that changed code and saw its tests pass leaves one more memory, the fix record: the cause, the definitions it changed beside their files, and the test commands that passed.
`Request.__init__` in http/request.py indexed the result of `parse_header` in
http/parse.py without a None check, so a None from `parse_header` crashed request
construction. Fixed in `parse_header` in http/parse.py and `test_empty_header`. Tests
passed after the change: `pytest tests/test_parse.py -q`.
A session capture holds what the user and the assistant said and no tool call, so what the session changed and which command ran its tests are read from elsewhere. The record is written only for a session that changed a file other than a test and whose last test run after its last change passed.
What the session changed. The plugins send it with the capture, as changed_files:
the files of the checkout that differ from their state when the session began, each with
the time it was last written. They are the files git diff --name-only lists against the
newest commit made before the session began (so what the session committed counts) and
the untracked files git does not ignore, without the ones last written before the
session. A tracked file of code (by its extension: a document, configuration and a file
without one carry none) also carries definitions: at most four names of the
definitions its changed lines are in, read from git diff -U0 against that commit (the
definition git prints in each hunk header, and each added line that opens one). Git
prints the nearest line above the change that starts in the first column, so a change
inside a method is named by its class unless the repository sets a diff driver for the
language, and a change to module-level code below a function is named by that function.
A file left dirty before the session that the session wrote again names the definitions
of both changes. Paths, times and names are sent, never content. From that list:
- one of the files must not be a test (a
tests/orspec/directory, a test-named file), and the record must name one of those. A file a test run itself wrote and git does not ignore (.coverage, a report) is one of them, so a session that changed nothing else but tests is asked for a record, and one that names only a test file is left out; - the session’s test runs are the ones seen no earlier than the second the last of the files was written, so a run seen in the same second as the last write counts as after it;
- which tool wrote a file does not matter: an edit tool,
sed -i, a here-document,git apply; - an edit that left no file changed does not count: a test file changed for a run and put back after it;
- a file that a pull, a merge, a rebase or a branch switch rewrote during the session counts as changed by it;
- a file of another repository inside the checkout (a submodule, a nested clone, a linked worktree) is not in the list, since git names that repository’s folder and not its files.
A capture carries no changed_files when it comes from another client, and from a
plugin when:
- the session’s folder is not a checkout, no commit is older than the session, or a git call fails;
- the session’s transcript is longer than 8 MB: the plugin reads its last 8 MB, which show neither when the session began nor every edit-tool call;
- a changed file was deleted, or more than 50 files changed;
- another repository’s folder inside the checkout was itself written during the session;
- an edit tool wrote a file the list would leave out: one outside the checkout (a plan or a note under the home folder), one git ignores, or one of another repository inside it. The plugins read the edit-tool calls from a Claude Code transcript, so a Codex session’s list is sent without this check.
Without the list, the session’s changes are its edit-tool calls among its tool
observations, each for the file the tool was given (the first file of a patch that
changes several), and its test runs are the ones after the last such call. Such a call
does not count as a change when the file was created after the session’s last test run
of any kind: a script that packages the patch, a note or an output file, inside the
checkout or outside it. No test run loaded such a file, so writing it leaves the last
passing run in place, and a record that names it is left out. The server reads the
creation from the tool’s result: Claude Code’s Write answers create for a file that
was not there, and for an empty one that was. Any other call counts as a change: one
whose result does not say that it created the file, one on a file that held text, one on
a file created before the last run.
A file changed through the shell is then not seen: a session that edits only that way gets no record, and after a shell change that follows the last passing run the record still says the tests passed. It says so too when a file of code is created, or an empty one filled, after that run; the record then names neither.
What ran its tests. The test runs are read from the session’s tool observations
(observe.record, which the plugins send after each tool call), in the order of the
calls. A command is a test run when it names a runner (pytest, tox, go test,
npm test, a runtests.py), or when what it printed closes with a runner’s summary:
unittest’s Ran 3 tests in 0.2s, counts beside the time the run took (2 passed in 0.03s, tests finished: 61 passed, 2 expected to fail, in 2.73 seconds), or 3 tests, 0 failures. A project’s own runner script and a runner started from python -c are test
runs that way. A script that prints All tests passed and no such summary is not one:
what it ran is not known, so its success writes no record and its failure after the last
passing run takes none away.
A command that only shows text is not a test run by what it prints, since the summary in
its output is an earlier run’s: tail -3 /tmp/test.log, a git diff of a test file. That
is a command whose every part, between ;, &&, ||, | and line ends, starts with
cat, tail, head, less, more, grep, rg, wc, ls, git, sed -n, echo,
cd, sleep or wait, and a tool call whose input names no command (a poll of a
background command’s output). The braces of a group are no command of their own:
{ cat a.log; } 2>&1 | tail -5 only shows text. A summary shown any other way
(python -c, a script that prints a log) is read as a run, and the record then lists a
pass that may have been seen before the last change.
The last run must show the summary a runner closes a clean run with: 2 passed,
unittest’s OK, # fail 0, Tests: 2 passed, 3 examples, 0 failures, or counts with a
duration and no failure among them, also in colour. A line a runner prints for one test,
file or package (ok 1 - adds, PASS src/a.test.js, ok pkg/a 0.2s) is not one, since a
failure may follow it. test result: ok and 3 passing, which a failure may follow too,
count only when the stored output was not cut. In an output that was cut, the summary is
read only after the last cut: one ahead of it may be an earlier command’s (pytest a && pytest b). A session gets no record, and its extraction prompt is the one above,
unchanged, when:
- it changed nothing but tests, ran no test after its last change, its last test run failed, or it sent no observations;
- the summary of its last run is not in the stored output. The plugins store the last 800 characters of what a command printed, from a line start, and the server the start and the end of a longer output a client sends whole. A runner that prints more than that after its verdict (a line for each of many parallel workers) shows no pass;
- the output of its last run was cut and its command may have run the tests again after
a run that failed, whose failure is then in the part that was not stored. That is a
command with a loop (
for,while,until), whatever the loop runs, or with two runs that anything but&&joins, as inpytest a; pytest b, or that&&joins after a piped run, as inpytest a | tail -5 && pytest b, where the pipe hides the first run’s status. A run is a pipeline (the commands that|joins, which run once, together) with a command that names a runner and does more than show text. In a command that names no runner outside quoted text (a project’s own script, a runner started frompython -c), every pipeline that does more than show text counts as a run, since any of them may be the one:bin/test a; bin/test bgets no record from a cut output, and neither doesexport X=1; bin/test aorsource venv/bin/activate; bin/test a | tail -30. With&&in place of;the last two get one. Quoted text is not read, except the script thatsh -corbash -lcis handed; - its runner prints no closing summary for the run (
go testprints one line per package).
The calls are ordered by the time the client saw each one (observed_at), in whole
seconds, and by their arrival when the client sends no time. Two calls of the same second
are read in the order they were written until observe.crystallize queues them, and in
no known order after it. An observation that never arrived is not known to be missing:
when it is the failing run after the last passing one, the record still says the tests
passed.
For a session that qualifies, the extraction call is asked for one fact tagged
fix-record: the cause in the code as it was before the edits, then “Fixed in” and each
changed definition in backticks beside its file. The record is then checked and completed
without a model:
- at most one per session, the last one the extractor wrote;
- it names a file the session changed (from a plugin’s list, one that is not a test) and
at least one definition in backticks, and holds no code fence and no line that starts
with
-or+; - in a capture without
changed_files, it names no file the session created after its last test run; - its
filesare the paths its own text names, so the code link pass links it to the definitions in them, follows their renames and marks it when they change (when it is linked); - its key is
fix_record_, the definitions after the last “Fixed in”, and a hash of them, of the files that clause names, of the capture’srepo:tags (itsproject:tags when it has none) and of the session: the key is one session’s fix of those definitions, and no other session’s record has it (two records of the same code); - its last sentence lists up to three test commands that passed after the last change.
A shell tool’s argv array is listed as the command it runs, without a leading
sh -corbash -lc. A command of several lines is listed by its lines that run tests, without the text of a here-document, and a run whose runner is named only inside such text counts as a run and is not listed: a session whose only passing run is one gets no record. A run known by its summary alone is listed by all its lines outside such text. The plugins keep both ends of a command longer than 800 characters. Of a line that holds the cut, the whole words before it are listed when they name the runner (the cut may fall inside the last word), and nothing of it otherwise. Nothing checks that those tests exercise the changed definitions.
A record that fails a check is not written. Its cause, the text before “Fixed in”, stays
among the capture’s facts, since the extractor was told to state it nowhere else, and is
tagged as a claim the session’s change ended
(facts the session’s change ended). A cause that
holds a code fence or a line that starts with - or + is not kept either.
loom.verify_durable is not shown the record: its rules drop a report of an edit, and the
session’s tool calls are what vouch for this one. A capture whose only fact is the record
makes no verifier call. A fact tagged fix-record in any other capture, such as a
trajectory replay, is judged like every fact. The record is written through
memory.bulk_set like every extracted fact, with the capture’s actor and source class.
The record without a model
On a deployment with LOOM_MEMORY_EXTRACT_SESSION_CAPTURES=false no extractor is asked
for the record. When the capture’s client named the definitions the change is in (the
definitions of its changed_files), the record is stated from them, at most six files
and four names of each, and from the commands that passed:
Fixed in `parse_header` and `Parser` in http/parse.py. Tests passed after the change:
`pytest tests/test_parse.py -q`.
The files stated are the ones a call of the session’s edit tool names, when the session made such a call: a file that a pull, a merge or a branch switch rewrote during the session is among the changed files with the definitions of other people’s commits, and is left out. A session with no edit-tool call wrote its change with a command, and every changed file’s names are stated. A session whose edit-tool calls name none of the changed files (an edit put back) states no record.
It says where the change is and which tests passed on it. It does not say what was asked
or what the cause was, and it quotes no turn of the session, whatever kind of change the
session made: “Fixed in” is the phrase every record names its definitions after. It
cites no turn either, so it is linked to its evidence like any fact the extractor left
uncited: to the turns that name its definitions or its files, else to the whole window,
and counted in the evidence.link drop ledger as a fallback. It carries the tags
fix-record and code, and is checked, keyed and
marked like the record a model writes. A name
or a path that cannot stand in such a sentence (a space, a backtick) is left out, and a
record left with no definition is not written. A default deployment does not use the
names: its extractor writes the record, with the cause.
The record and the code on trunk
The code link pass links a memory against the repository’s trunk, and a record is
written when its session ends, which is usually before its change is merged. Trunk then
has the definitions after “Fixed in” as they were before the change, or does not define
them yet. Those names wait, as
pending names do. The change is one
event for the record: its names are linked together at the first indexed commit that
shows it, which is the first whose text of one of those definitions is not the one trunk
had when the record was first read (or that defines one at all), or the first that has
in its history the commit the record names (change:<commit>):
| When | What the record reads |
|---|---|
| Before the change is merged | The definitions that only its cause names are linked as trunk has them, and each file whose only named definitions wait gets a file link. The waiting names are not served. |
| Once the change is on trunk | Each definition after “Fixed in” is linked fresh at that commit, also one whose own text the commit left as it was. A file after “Fixed in” with no such link is read again at that commit, and a name there that is no one definition (a class two of the files define, an attribute) is dropped. |
| After a later edit | changed, as for any memory. |
The change is not on trunk within memory_code_links_pending_days (14 by default) |
The names are dropped, and the record keeps its other links. |
A commit that changes the file and leaves the definitions’ text as it was is not the
change. Without a commit the record names, trunk’s text is the only evidence read: an
edit of one of the definitions by someone else that lands first is taken for the change,
and the record’s own change then reads changed. A record whose change was already on
trunk when the pass first read it (the session merged it before it ended) is linked at
once when it names the commit and trunk has that commit; one that names none, or whose
change reached trunk as another commit (a squash merge), waits for the next edit of
those definitions, and is linked to its files until then. A record none of whose names
is a definition on trunk is never seen to land without a commit: its files read
changed once its change is there. A record rewritten after its names were linked is
linked like any rewritten memory, at the head of that time.
Facts the session’s change ended
Most of what a capture keeps holds after its session’s own change: how a behaviour is reached, what has to change together, an invariant and its reason. Two kinds of fact do not: the cause of a bug the session then fixed, which is stated as the code was before the session’s edits, in the present tense, and the fix record, which says what the session changed. Once that change is in a checkout, such a fact describes code that is no longer there.
The extractor reads the claim beside the session’s change, so it decides: the
coding-session prompt asks it to tag a claim that the session’s edits made untrue with
session-change, and no claim that still holds with them applied. The tag stays on a
fact whose own text names a file the session changed (a file that is no test), which is
the evidence of a change that the session’s tool calls give, and is taken off any other.
A file that only a turn the fact cites names does not count: the claim may be about
another file. The fix record gets the tag too, and so does the cause of a record that is
not written, each when its own text names such a file. A record that names only a test
file among the session’s edits, which a capture without changed_files can write, is
not marked. The changed files are the ones the fix record reads, changed_files or the
session’s edit-tool calls, whether or not a test run passed after them. The text names a
file by a path relative to the repository, or by the path from the root of the file
system that the session’s edit tool was given for it. A fact about a changed file that
the extractor did not tag is not marked.
A capture’s client that knows which commit holds the session’s change sends it as the
tag change:<commit> in extra_tags (a full commit id; any other text names none), and
the marked facts carry it, no other fact of the capture. The
Claude Code plugin sends the checkout’s HEAD when the session changed files, nothing in
the checkout is modified or untracked at its end, and HEAD’s history has a commit made
since the session began that touches every file the session’s edit tool wrote. A session
that commits its change on one branch and ends on another that lacks it sends no commit,
and neither does one whose transcript shows no edit-tool call, which is every Codex
session: the hook does not read Codex’s patch tool.
No read leaves such a memory out: a checkout is the caller’s, and Loom does not see it.
context.pack says what it knows:
- the line of a marked memory carries
changed_in=<commit>(twelve characters), orchanged_in=unknownwhen no commit was sent, and the memories block opens with one sentence on what the label means; section_meta.memories.session_changeslists, by citation, each marked record it serves:commit, and for a fix recordfixed, what to state of it in a checkout that has the commit: its text from “Fixed in” on, or the excerpt its line shows when the excerpt does not hold the whole record.<and>are escaped in it as in the line.
A client that holds the checkout decides with them. Before a prompt, the plugins ask git
whether HEAD has the commit in its history (git merge-base --is-ancestor, once for
each commit, a second at most for all of them; a commit git does not answer for in that
time counts as one HEAD does not have): a marked fact whose commit it has is not added
to the prompt, a fix record
whose commit it has is added as its fixed text in one line (fixed_in=<commit>, which this checkout holds), and a marked record with no commit, or one the checkout does not
have, is added after the records that are not marked. memory.search and loom_search
serve the memory as written.
What the mark does not cover:
- The tag is the extractor’s reading of the session. A cause it does not tag is served as written in every checkout.
- No test run has to pass for the mark. A session whose last test run after its change failed is marked like any other: a claim the extractor tagged there carries the mark, and the commit when the session committed its work, so a prompt in a checkout with that commit does not get it, although no run shows the defect gone.
- A session that ends with a modified or untracked file names no commit, and its marked
facts read
changed_in=unknown. So does one that ends on a branch without its own commit, one whose change is spread over commits of which none touches every file its edit tool wrote, and one that changed files only through a command. A later capture of the same session that states a fact in the same words reinforces the stored row and leaves its tags as they are, so it does not add the commit. - The plugin names
HEADfrom the files a commit touches, not from their content. A session that commits its change on one branch and ends on another, where a commit made since the session began touches every file its edit tool wrote, names that branch’s tip, which may lack the change. - The commit is the one the session made. A change that reaches a later checkout as another commit (a squash merge, an amended or rebased commit) is not in that checkout’s history, so the record is added as written, after the unmarked ones.
changed_filesholds every file written in the checkout during the session, also by a pull, a merge, a rebase or a branch switch, so a tagged fact about such a file is marked as well.
Two records of the same code
The key holds the session, so a later session that fixes another bug in the same
definitions writes a second record, and no rule about a shared key joins the two: under
newest_wins the later one does not retire the earlier one, and the shared-key mark of
auto_reinforce and manual_review has nothing to mark. A plugin’s capture names no
user, so that mark would not apply to it in any case. The write compares a record with
the stored rows by text, as it does any memory
(conflicts and refusal):
| Policy | A record close in text to an earlier session’s record |
|---|---|
auto_reinforce (default) |
Both are flagged conflicted and stay served. The conflict resolver clears a compatible pair and retires the earlier one only for an update it is sure of. |
manual_review |
Both are flagged and stay served. The conflict resolver clears a compatible pair and retires neither. |
newest_wins |
No key is shared, so nothing is retired by key. By text, as under auto_reinforce; a record that is the earlier one’s sentence with one value replaced retires it (refines), as for any memory. |
append_only |
Each is written with no verdict. |
Two sessions that record the same fix leave two rows unless that check finds the later
one a merge or a duplicate: loom.verify_durable, whose restatement check reinforces a
stored memory in place of a new row, never sees a record. A later capture of the same
session has the same key and identity, so it writes no second row: another wording
revises the session’s row.
Rules the assistant states about itself
A chat bot’s replies carry rules about its own behaviour: “I escalate any refund over
$500 to a human”, “I always answer in bullet points”. With
LOOM_MEMORY_EXTRACT_AGENT_LEARNINGS on (off by default; a live setting:
loom settings set memory_extract_agent_learnings true turns it on without a
restart, see runtime settings), the extraction
call also returns these, marked "about": "agent", at no extra model call. The setting
is the only way on: a request’s agent_learnings=false turns it off for that call, and
agent_learnings=true while the setting is off is ignored and named in ignored_args
(and the X-Loom-Ignored-Args header). It adds a block to the extraction prompt. Turn
it on, and review assistant_turn candidates, only once no replica runs a build
without it: an older build does not erase loom.learnings_supporters, and on promote
it writes the bot’s rule as the approver’s own memory
(rolling upgrades). Before rolling back to
such a build, turn it off, then delete the rows of loom.learnings_supporters, where
users’ quotes live (an older build’s erasure does not cover that table), and the
assistant_turn candidates
(ALTER TABLE loom.learnings_queue DELETE WHERE source_kind = 'assistant_turn').
Coding captures never use it.
Behaviour the assistant agrees to at the user’s request is the user’s preference, not a rule of the bot: “always answer me in French” answered with “I will always answer you in French” is a memory about the user. The extraction prompt says so, and no check after it reads the user’s request: a rule the model still returns for such a request is filed, and the reviewer rejects it.
Such a rule is never written as a memory. An end user can talk a bot into saying
anything, and a memory at the agent’s level would reach every user of the bot. The rule
becomes a pending assistant_turn candidate in the
learnings review queue for the
request’s (org, namespace, agent):
- A candidate is keyed by the agent, the rule’s memory key and its text, with only case
and spacing folded and a trailing period dropped. A different rule under the same key
is a separate candidate, so a first wording never collects the support of a later
one. The same rule worded differently in another session is a separate candidate too,
so wording drift splits its support. The extractor’s key rewrites leave a rule’s key
alone. While a bot’s rule promoted to knowledge is served, no new candidate is filed
for that bot under that key: a promoted rule is served back to the bot, which
restates it in its own words, and each restatement would otherwise wait for review
again. The skip is counted in
loom.memory_drops(stagelearnings.file, reasonalready_promoted). Only a knowledge promotion stops new filings under its key: a rule promoted withdestination="memory"leaves nolearning://<candidate_id>document, so each restatement of it is filed as a new candidate. To revise a promoted rule, delete itslearning://<candidate_id>document withknowledge.delete: a new wording under its key is then filed as a new candidate; the promoted wording itself stays decided and its restatements are counted under reasondecided. Rejecting a promoted rule leaves its document, so the rule is still served and still stops new filings; delete the document to stop serving it. A rule rejected before any promotion is never served back, so it stops only its own wording: a different rule under its key is still filed. - The candidate row holds the rule and no user’s words. Each session that states it adds
a row to
loom.learnings_supporterswith the end user, the session and that user’s own quotes: the user turn before the cited assistant turn (up to 200 characters) and the rule as said, the span the extractor cited when a cited assistant turn contains it, else that assistant turn (up to 400). A rule whosesource_message_indicesname no assistant turn is not something the assistant said: it is never filed, and the drop is counted inloom.memory_drops(stagelearnings.file, reasonno_assistant_turn). A rule that reads as high is never filed either, and the drop is counted under reasonsensitive; nor is one that matches a blacklist pattern. A quote that does either is stored blank. The supporter row is written first, then the candidate row again, at version 1, with every new supporter. So an erasure that deletes a pending candidate mid-filing never leaves that supporter without it. A review always writes a newer version, so the rewrite never undoes a decision, and a decided candidate takes no new supporters: its restatement is counted inloom.memory_dropsunder reasondecided, so a rejected rule that keeps coming back shows there. A restatement after the first filing never changes the candidate’s text; two sessions that first file the same rule at once, differing only in case or a trailing period, leave either wording. learnings.listshows the earliest remaining supporter’s quotes as therationale. A user erasure deletes that user’s supporter rows, so the next supporter’s quotes show. A candidate left with none is deleted when pending; when decided, it keeps its decision with the rule blanked.- Support never promotes a candidate. An admin’s
learnings.reviewdoes. By default the rule is published to the namespace’s knowledge (learning://<candidate_id>, taggedagent:<agent>; the tag names the bot, and the document’s author is the reviewer). The agent reads that serve knowledge serve it to that bot only, for every user, a user bounded to their own rows included:context.packwithinclude_knowledge,memory.stack,loom_searchandmemory.ask(its knowledge passages and its whole-document route). Another agent in the namespace is not served it. Over HTTP, a namespace-wide read (agent*, thememory.askdefault) spans every agent and is served every bot’s rules; a read under no agent (-, theloom_searchdefault) is served no rule promoted for a named bot, so a bot names its agent there. Over MCP an unnamedagentis the client’s (claude-code, …), so those reads serve that agent’s rules. A rule filed for every agent (-) carries no agent tag and is served to every read.knowledge.searchis not filtered by agent; a bot finds its own rules withknowledge.search(tags=["agent:<agent>"]).destination="memory"writes the agent’s memory row instead (user_id-,source_tracelearning:<candidate_id>), which namespace-wide reads find and a read bounded to one user does not. - A token pinned to one end user (
read_user_id) files for the agent it names, never the body’sagent; any other token, anown_usertoken without a pin included, files for the body’sagent. An end-user token names the agent its issuer signed (itsagentclaim). A token Loom mints names no agent, so one pinned with--read-user-idfiles no bot’s rule. Its reads are served that agent’s rules the same way, and no rule promoted for a named bot when it names none (a rule for every agent is still served): a bot that needs its own promoted rules for a user reads with an end-user token signed for it, or with an unpinned token.
learning_candidates in the response counts the rules that wrote a new candidate or this
session’s support of one. A failed queue
write is named in pipeline_errors and the rule is dropped.
Echoes: recalled_keys and session_values
Most junk in session captures is the session repeating what Loom already told it. Two fields let the pipeline drop it:
| Field | Limit | Content |
|---|---|---|
recalled_keys |
200 | Keys the session’s Loom tools served. A fact whose key carries a served key’s subject words is an echo. |
session_values |
100 | Text the session’s Loom calls carried (values written, queries, results). Not in the MCP schema. A fact quoting one is an echo. |
The Claude Code and Codex plugins send both at SessionEnd. A custom client should too;
otherwise a session that asked “what do I drink?” writes the answer back as a new fact.
See Claude Code.
Fact quality on the read side
A deterministic classifier (server/memory/domain/fact_quality.py) runs on agent-facing reads
(loom_search’s memory section and context.pack’s memories, through the
quality_filter field of memory.search). It leaves out trajectory steps, session
narration, generic tool hints, code locations the code index answers exactly, probe or
placeholder writes, one-moment status, and restatements of a higher-ranked fact. Nothing
is deleted.
To clean stored rows, loom demote-activity-narration demotes (confidence × 0.25) or
labels them through memory.apply. It is a dry run without --apply;
--classifier fact_quality applies every junk class; keys an agent read by name in the
last --days are left alone. It never deletes.
Inline or deferred
| Mode | Call | Returns | Use when |
|---|---|---|---|
| Inline | defer unset (the default) or defer=false |
written[] with each row’s key and verdict |
You need the keys back: typed-record extraction, tests, polling backfills. |
| Deferred | defer=true |
deferred=true, queue_id, empty written |
The agent’s hot path. Stored in loom.memory_extraction_queue. |
| Deferred by operator | LOOM_EXTRACTION_DEFER_AGENTS |
as deferred, deferred_by="allowlist" |
Force named agents (or * = every service account) that do not send defer onto the queue; an explicit defer=false still extracts inline. |
The extraction_queue worker replays a deferred request through the same handler. A
failed replay waits 15 seconds, then 1, 5 and 30 minutes between attempts, and after
LOOM_EXTRACTION_QUEUE_MAX_ATTEMPTS (8) becomes failed with last_error. A model
provider or gateway that cannot be reached (no connection, a timeout, 502, 503 or 504)
spends no attempt, except a read timeout from a local model server, which answered too
slowly for that request; on a local provider a replay cut short, at the pass deadline
(LOOM_EXTRACTION_QUEUE_MAX_PASS_SECONDS) or by a shutdown, spends one too. A replay
whose model call is held (the org’s model calls switched off, or the enqueuer’s identity
refused or asked to wait by the gateway) becomes held with the reason until the hold
ends, also with no attempt spent; meanwhile the worker claims other work, none of that
enqueuer’s requests in the namespace. A request still waiting a day
before the queue’s 30-day TTL is dropped with a loom.memory_drops record.
memory.extraction_status reports batches by queue_id or status (pending,
running, held, done, failed); a token bounded to one user sees only that user’s
batches. Until a batch runs, memory.search and memory.ask report
pending_extraction. With the worker off, deferred saves stay pending.
Model spend is recorded as one worker.extraction_queue ledger row for each replay that
spent, under the request’s namespace, agent, user and session, whether the replay
finished, failed or was cut short. It counts toward the namespace’s and the user’s
daily spend caps.
memory.extraction_status is an HTTP and SDK view, hidden from MCP. An agent follows up
on its own batches over MCP, through loom_op, with two ops that take the queue_ids
its deferred calls returned, at most 20 a call:
memory.extraction_status_minereports each batch’s state, attempts, sizes and last error.memory.extraction_retry_mineaccepts the caller’sfailedbatches for one more attempt.requeuedmeans the retry was accepted: an asynchronous in-place update eventually changes status topending. A failed replay endsfailedagain; batches still waiting or done are left alone. The update targets the exact version read, preserving newer worker results and never restoring an erased transcript. While the org’s model calls are switched off no new retry is accepted (model_calls_off); one accepted earlier and not yet applied stays inrequeued. A batch queued 29 or more days ago is not accepted (expired): the queue drops it before its 30-day TTL. A batch dropped while model calls were off can be retried once they are back on; itsloom.memory_dropsrecord stays as the history of that drop. Asking again while an accepted retry is still unfinished insystem.mutationssubmits no second update; two calls at the same moment can each submit one, and the later changes nothing.
Both answer only a batch the calling principal queued in that namespace, inside the
token’s read scope; every other id comes back in unknown, so an agent cannot learn
whether another principal’s batch exists:
- The principal is the token’s
kind:subject, the enqueuer a deferred call stores. Each token minted under Settings → Tokens and each delegated token is its own principal: a newly minted token, another client, or the token’s creator does not see the batches another one queued. Subjects compare as stored, so a human subject spelled differently is another principal. - The read scope. A token pinned to a user (
read_user_id) sees that user’s batches only. A token whose scope needs a session, or a user it does not pin, is refused: these ops take nouser_idorsession_idto complete it. - Auth off. A call carries no principal and sees the batches queued without one.
Operator extraction policy
An org admin can say once what extraction never stores, for the whole org or for one namespace, and no request can drop or override it, on the dashboard’s Guardrails page or over the API:
curl -sX POST http://localhost:7777/v1/extraction_policy.set \
-H "Authorization: Bearer $ORG_ADMIN_TOKEN" -H "Content-Type: application/json" \
-d '{"org":"acme","scope":"org",
"policy":"Never store credentials, payment card data or health data."}'
- Scope. Every call names its
scope:org(the org’s own policy;namespaceis ignored, since an MCP session fills it in) ornamespace(rules thatnamespaceadds to the org’s). An extraction in a namespace runs under both, the org’s rules first. The namespace is the one the request resolves to: an end user’s@meruns under the policy set for their personal collection’s name, and@meitself is refused as a scope. A namespace policy covers that namespace only: a child collection does not inherit its parent’s, so a rule for a whole subtree belongs in the org’s policy.extraction_policy.getreturns a scope’s policy and theeffectivetext its extractions run under; for scopeorgit also lists innamespace_policiesevery namespace that holds a policy of its own.extraction_policy.clearremoves one scope’s policy: clearing a namespace’s leaves the org’s in force, and clearing a scope that holds none writes nothing. A policy is at most 4,096 characters. - Bound. An org holds its own policy and at most
LOOM_EXTRACTION_POLICY_MAX_NAMESPACESnamespace policies (1,000 by default; one more is refused). Deleting a namespace leaves its policy in place: it still counts toward the cap, and applies again if the name is registered later, untilextraction_policy.clearremoves it; the org-scopeextraction_policy.getlists them. Every server holds every org’s policies and reads them all at each refresh, so the cap bounds each org’s share of that read (about 4 million characters at the default: about 4 MiB of ASCII text, up to 16 MiB of multi-byte text); the read grows with the number of orgs that hold a policy. A rule for every end user belongs in the org’s policy, not in a policy per personal collection. - Who. All three ops need
org_adminof that org; setting and clearing are audited. A writer, a namespace admin or an end-user token can neither set, clear nor read a policy. - Precedence. The policy ends the model’s system prompt, after the request’s
extraction_instructions, inside anOPERATOR EXTRACTION POLICYblock that says it overrides every other instruction and anything the messages say. No request field carries or removes it. - What follows it. Every model call of the memory, knowledge and observe planes
that writes stored text from raw text:
memory.set_from_messagesinline and deferred (the queue reads the policy when it replays the request) with its retries and its coverage sweep, the typed-record value stage, the session digest, observation replays from theobserve_extractworker and that worker’s event and hint notes, theconversation.compactsummary, thesession.brief_saverewrite, the context linesmemory.bulk_setwrites withcontextualize=true, and the conversation titler. The block stays last, after any retry addendum. The code plane’s model-written file cards and chunk descriptions describe indexed source, not a conversation, and do not follow it. Neither do the model passes over rows already stored rather than over raw text, such as period digests, profile consolidation, contrast reflections,memory.consolidatemerges, the structured profile worker (server/memory/workers/structured_profile.py) and the entity extractor (server/memory/workers/entity_extractor.py). Those rows includememory.setvalues, which no policy filtered. - The trade-off. While a policy is in force, the deterministic passes that add rows
the model left out, or copy from the raw turns what the model did not write, do not
run: recovered preferences, costs and ages; facts an assistant turn states as the
user’s premise; a forget request’s correction kept in the user’s own words; code file
paths and concepts taken from the cited turns rather than the fact (a fact keeps those
in its own text); a fact’s
speaker:<name>tag and name entity taken from the cited turns; and the action and file paths that an observe event or a hint note copies from the raw tool calls. The model may have left those out because of the policy, and these passes cannot read it. An extraction under a policy can therefore keep fewer facts than the same extraction without one.session.brief_savenever runs its deterministic builder under a policy (session briefs).memory.set_from_messagesanswersunder_operator_policy: truewhen it ran under one (a deferred request answers false: its extraction runs later, under the policy then set). - Cache. The extraction response cache keys on the whole prompt, so a changed policy never serves an answer cached under the old one.
- Propagation. Every server reads the policies at most every
LOOM_MODEL_CALLS_POLICY_REFRESH_SECONDS, and the server that took the change reads them at once. A server that cannot read them forLOOM_MODEL_CALLS_POLICY_MAX_STALE_SECONDSrefuses inline extraction andconversation.compactwith 503 and leaves queued requests and threads to title waiting, rather than call the model without the policy;session.brief_savealso answers 503 (the client sends the events again),bulk_setwrites its entries without context lines, and theobserve_extractworker leaves its sessions to distill later. A replica of a build that predates the policy table extracts without it; set a policy once every replica runs a build that reads it (rolling upgrades).
The policy is an instruction to the model, not a filter: Loom does not check a written
row against it. It does not change what is stored verbatim: evidence rows, verbatim
chunks and recorded observations keep the turns as sent, and memory.set and
memory.bulk_set write the caller’s own text (bulk_set’s contextualize lines are
the one model-written part, and they follow the policy). Pair it with the
blacklist for exact patterns that must never be written.
Operations
| Op | Role | Does |
|---|---|---|
memory.set_from_messages |
writer | Extract facts (or one typed record) from messages and write them. |
memory.extraction_status |
viewer | State of the namespace’s deferred batches. HTTP and SDK only. |
memory.extraction_status_mine |
viewer | State of the caller’s own deferred batches, by queue_id. Over MCP as well. |
memory.extraction_retry_mine |
writer | Replay the caller’s own failed batches once more, by queue_id. |
memory.recall |
viewer | Search the raw turns behind the namespace’s memories by text, time and role. |
memory.evidence |
viewer | The source turns one memory was extracted from, with the supporting span. |
observe.record |
writer | Record one tool observation into the episodic plane; no model call. |
observe.crystallize |
writer | Mark a session’s observations ready for the observe_extract worker. |
extraction_policy.set |
org_admin | Set the org’s or a namespace’s extraction policy. |
extraction_policy.get |
org_admin | Read a scope’s policy and the effective one. |
extraction_policy.clear |
org_admin | Remove a scope’s policy. |
Field lists: operations reference, observe and extraction_policy.
Request fields
| Field | Effect |
|---|---|
messages |
1–400 turns: role, content, optional timestamp (anchors facts to the turn) and name (speaker). |
last_messages |
Up to 20 earlier turns, shown for context and not re-extracted. |
observation_date |
YYYY-MM-DD anchor for relative dates. Unset: LOOM_MEMORY_EXTRACT_OBSERVATION_DATE_DEFAULT (request_time, today UTC). |
extra_tags |
Added to every extracted fact. source:<client> marks a coding capture. |
extraction_instructions |
A prompt suffix (up to 4,096 characters). The operator’s policy outranks it. |
record_schema + memory_key |
Extract one typed record (typed records). Never deferred by the allowlist. |
valid_at |
Fallback validity time for facts the extractor did not anchor. |
recalled_keys |
Keys the session was served (echoes). |
defer |
true queues instead of extracting inline; false extracts inline even for an agent on LOOM_EXTRACTION_DEFER_AGENTS. |
agent_learnings |
false stops filing the assistant’s rules for this call (above); only the setting turns it on. |
Response fields
written[]: key, version,conflict_verdict,peers.tokens_in,tokens_out,cached_tokens_in: cost attribution.segments,segmenter(wholeorsize).forgotten,forgotten_keys,evidence_ids.learning_candidates: rules that wrote a new candidate or this session’s support of one.ignored_args: request fields not applied: unknown keys, andagent_learnings=truewhile the setting is off.stage_ms: wall time per stage (step.<step_id>,bulk.<phase>).observation_date_source:caller,request_timeor empty.stubbed_fields: typed-record fields written as null after validation retries.pipeline_errors: fail-open steps that were skipped, such asunknown_step:<id>.
Example
Inline, with the Python SDK:
from loom import Agent
async with Agent(org="acme", namespace="support", agent="triage-bot") as bot:
out = await bot.memory.set_from_messages(
[
{"role": "user", "content": "I moved to Lisbon last month, please bill me in EUR."},
{"role": "assistant", "content": "Noted, invoices will be in EUR."},
],
user_id="u-42",
observation_date="<YYYY-MM-DD>", # the day the conversation happened
)
for row in out["written"]:
print(row["memory_key"], row["conflict_verdict"])
Deferred, over HTTP, as a session-end hook sends it:
curl -sX POST http://localhost:7777/v1/memory.set_from_messages \
-H "Authorization: Bearer $LOOM_API_KEY" -H "Content-Type: application/json" \
-d '{"org":"acme","namespace":"support","agent":"triage-bot","user_id":"u-42",
"messages":[{"role":"user","content":"Our on-call rotation changes to weekly."}],
"recalled_keys":["team/oncall/rotation"],
"defer":true}'
# → {"deferred": true, "queue_id": "...", "written": [], ...}
The SDK’s set_from_messages does not expose recalled_keys, session_values or
pipeline_steps; send those over HTTP or MCP.
Settings
See the Extraction section unless noted.
| Setting | Effect |
|---|---|
LOOM_LLM_PROVIDER, LOOM_LLM_MODEL |
The extraction model. Run make bench-quick before changing it. |
LOOM_MEMORY_EXTRACT_SESSION_CAPTURES |
false: a plugin’s session capture makes no model call (the lowest-cost mode). |
LOOM_MEMORY_EXTRACT_VERIFY_MODELS |
The models loom.verify_durable asks; a model whose provider key is missing is skipped. |
LOOM_MEMORY_EXTRACT_VERIFY_TIMEOUT_S |
Per verifier call; a timeout keeps every fact. |
LOOM_MEMORY_EXTRACT_SIZE_SEGMENT_* |
When a long session is split into fixed windows, and their size. |
LOOM_MEMORY_EXTRACT_COVERAGE_SWEEP_* |
A second reading of turns the first pass cited nowhere (one more call). |
LOOM_MEMORY_EXTRACT_VALUE_UPDATES |
Off by default: supersede an older memory when a fresh one restates it with a different value. |
LOOM_MEMORY_EXTRACT_AGENT_LEARNINGS |
Off by default: file the assistant’s rules about itself for review. |
LOOM_EXTRACTION_QUEUE_*, LOOM_EXTRACTION_DEFER_AGENTS |
The deferred queue: cadence, pass deadline, lease, attempts, concurrency, forced deferral. |
LOOM_OBSERVE_EXTRACT_* |
The observe plane’s distillation worker (off by default; makes model calls). |
LOOM_MEMORY_CHUNKS_MAX_PER_CALL |
Verbatim chunks one call writes (Chunking). |
Workers
| Worker | Role | Default |
|---|---|---|
extraction_queue |
Replays deferred requests. | on |
observe_extract |
Distils observe.record observations through the same pipeline. |
off |
entity_extractor |
Fills entities on rows written without them. |
on |
embedding_worker |
Embeds embedding_dim = 0 stubs and memories with no embedding row. |
on |
Cadences and switches: workers reference.
Limits
- Extraction failure is fail-closed. An error from
loom.llm_extractanswers 502EXTRACTION_FAILEDand writes nothing. Every other step fails open and is named inpipeline_errors. - Drops are counted, not returned. Parse, judge, truncation and chunk-cap losses go to
loom.memory_drops(kept 30 days);loom drops --namespace NS [--hours 24]sums them. - At most 400 messages and 20
last_messagesper call. Split longer imports. - Custom pipelines are global and sequential. No per-namespace pipeline, branching or step retry.
- Re-extracting a namespace into a fresh one is
loom reextract --org ORG --namespace SRC --into DST; the source is only read.
Related
- Writing memory
- Conflicts and refusal: the verdicts in
written[]. - Extraction pipeline guide
- Conversations and sessions
- Memory architecture