Memory linked to code for coding agents
Link agent lessons to functions, classes and files. Check what stays current across trunk and release branches as code changes, moves or disappears.
Loom links coding agents’ memories to the functions, classes and files they name, follows
them through refactors, and flags a memory when its code changes. By default, search leaves
out a memory whose code is all gone unless a person pinned, locked or verified it, and every
read that serves a lesson says when its code changed or is gone. It runs over MCP, HTTP and
the SDKs on the repositories a self-hosted Loom indexes (the
code index), and the
memory_code_links worker that keeps the links is on by default.
To see the change in a read response, save a lesson, edit its source and check the reported commit.
What you get
- Lessons attached to the code they are about. A memory tagged
repo:<id>(the Claude Code and Codex plugins tag the lessons extracted from a session’s transcript) or written in the repository’s code namespace is linked to each definition (function, class or other symbol) it names in backticks, or anywhere in its text asA::bor a call (a.b(),name()), that resolves to exactly one place (an unqualified name needs four or more characters); to definitions in the files it lists that it names by a bare camelCase or snake_case word; and to each file it lists that holds none of them. The worker retries pending names as definitions reach trunk. Memories linked to code - Links that follow refactors. On every indexed commit, each link reads
fresh,moved,changed(naming the commit that changed it),unresolvedormissing. A link records the definition’s tokens, so whitespace, comments and most formatter changes leave itfresh. A definition renamed as it moves to another file or class is followed when one new definition there is it:movedwith the same tokens,changedwith a small edit or outside its class. A link to a file follows the lines that hold a name the memory cites, and is replaced by a link to a definition the memory names once the file defines it. Link states - The current name beside a memory written against the old one. While a memory’s
text still says the old name, these reads name where the code is now:
memory.get,memory.searchand theloom_searchtext,memory.for_fileand the pre-edit block,lessonson code answers,context.packand the dashboard, and the notememory.askgives its synthesis (where the deployment setsmemory_ask_code_namespaceto a code namespace the caller may read and leavesmemory_ask_code_stalenesson). A line reads(code moved: `reader::fetch_rows` is now `reader::load_rows` at src/reader.py:12-40), and the structured answer carries the same ascode_moved. What reads name - Stale memories handled the way you choose. The namespace’s
code_change_policydecides:retire_removed(the default) leaves a memory whose code is all gone out of search and flags changed code;flagonly flags;revisealso leaves gone-code memories out, and has the model check a changed one’s claim against the old and new code: one that still holds is re-anchored, and a contradicted one gets a suggested correction. A memory a person pinned, locked or verified is never left out. Under every policy, search usually ranks a memory whose code changed below the next three results instead of hiding it; a held memory and a row found by name keep their place. No policy rewrites the memory. Policies - Lessons wherever the agent reads code.
code.symbolreturns the memories linked to a definition aslessons;code.search,code.callers,code.callees,code.impact,code.outlineand a task’scode.context_packattach the lessons for the files they return; each lesson carries its link state. A slow or failed file read leaves the completed files’ lessons intact within the enrichment timeout. An edit lookup can include fresh lessons from an indexed caller when it returns that caller’s verified source. The Claude Code and Codex hooks show a file’s memories (memory.for_file) before an agent edits it, and the Cline hooks when it reads or edits one.code.symbol· Claude Code plugin · Codex plugin · Cline hooks (experimental) - Shared with the team. Lessons are read from the repository’s code namespace and the namespaces the call names (over MCP, the caller’s own by default), so a lesson saved in the repository’s code namespace reaches every agent that may read that namespace (a token narrowed to its own user or session reads no lessons). Memories linked to code
- Branches read their own code. On another branch, a lesson is checked against that
branch’s own definition, so a release branch that still has the old text reads
fresh(on a host withLOOM_GIT_HISTORY=none, which has no git mirror, a lesson carries trunk’s state). Memories linked to code - Documents beside the code. Documents from a source registered on the repository’s code
namespace (its trunk’s) carry the repository’s tag, so searches over the repository read
them with its code (the sync worker needs
LOOM_KNOWLEDGE_SOURCE_SYNC_ENABLED). Document sources - A review list.
namespace.validatelists the memories whose code changed, was not found again or is gone, and the dashboard shows each memory’s links and their state. - Text that follows a rename. After a rename or a move the link follows with the code unchanged, the link pass swaps the old name or path for the new one in the text of a lesson written in the repository’s code namespace, where the swap is certain, nobody holds the lesson and the repository is indexed on one branch. The same report lists the exact token edits for every other lesson, or the reason it offers none. Bring a lesson’s text up to a rename

Start
Quickstart boots Loom, and
adding repositories turns the code index on for a
repository. Connect your coding agent with its plugin or over MCP
(connect a coding agent). Save a lesson that
names a definition of four or more characters in backticks or as a call (`name()`), or
a qualified one such as `Reader.run`. The Claude Code and Codex plugins tag the
lessons extracted from a session’s transcript with repo:<id>, and the session primer names
the id
(how it is derived). A lesson the
agent saves itself with loom_memory_set links when it carries that tag
(tags: ["repo:<id>"]) or is written in the repository’s code namespace; any client can do
either. Over HTTP (or agent.call in the Python SDK), a lesson saved in your own namespace
is read only when the call names that namespace in lesson_namespaces. Each link pass links
writes at least 60 seconds old and passes run every 60 seconds, so once trunk is indexed,
code.symbol on that definition returns the lesson under lessons within about two
minutes.
Check a lesson after a code edit
On the repository’s indexed trunk, save a lesson such as `fetch_page()` retries on code 115
with the repository tag or in its code namespace, as above. Use a name that resolves to
one definition. After the link pass, read that definition with code.symbol and look for
the saved memory under lessons. When included, it carries code_state: "fresh".
Include the memory’s namespace in lesson_namespaces when the call needs it.
Change an expression in the function’s body, such as return url to return url.strip().
Commit the edit and push it to the indexed trunk. After the index and link worker process
the commit, read the definition again in the same trunk namespace. Under the default policy, a returned
lesson carries code_state: "changed"; changed_since names the indexed
commit. This marks changed code, not a judgment that the lesson is false. Read the
current body before applying it. Uncommitted editor changes do not trigger this check.
Symbol cards cap the lessons they return and can omit the saved lesson. If it is absent,
use memory.get to inspect that memory’s code links and their states.
The existing test_memories_follow_their_code
integration regression
checks these states across commits. It also checks a pure move (moved), removed code
(missing) and a release branch whose unchanged definition still reads fresh.
To see a rename, change only the function’s name on trunk and push. With the repository
indexed on one branch and a lesson written in its code namespace that writes the name in
backticks or as a call, the link worker rewrites the name in the lesson’s text in the
pass that follows the commit, and after the next pass memory.get lists the link under
code at the new symbol, fresh. Where the lesson keeps its text (it is written in
another namespace with the repository tag, it is pinned, the repository has a second
indexed branch, or the name is written as a word of the prose), memory.get lists the
link with the new symbol, its start_line and end_line, and was_symbol, the name
the lesson’s text still uses. A search that serves the lesson carries the same link in
code_moved, and its line in the loom_search text names both.
The packaged MCP smoke
saves a lesson, verifies fresh, commits a body edit and waits for the indexing and link
workers to return changed with that exact commit. The
quickstart harness
restarts the Loom service, checks the link again and deletes the test memory.
CI runs these checks
on amd64 and arm64 with authentication off, a local embedder and a fake model provider.
These checks verify code-link state; authenticated clients, answer quality and agent
tool selection are not tested.
For removal, held-memory exceptions and model-backed revision, see the link policies.
Bring a lesson’s text up to a rename
When a definition is renamed or moved with nothing else changed, its link follows it and
reads moved. A lesson that wrote the old name, module or path still says it. The link
pass revises the text itself when the lesson is written in the repository’s code
namespace, the edits are certain, no person pinned, locked or verified the lesson, no
service account attested its text, and the repository is indexed on one branch
(what it writes). A lesson
written in another namespace with the repository tag keeps its text: the tag grants
nothing, and that namespace’s readers may hold no role on the repository.
The revision keeps the lesson’s writer, and memory.history shows the text it replaced.
A lesson its writer asserted is marked derived; any other keeps its source_class.
A lesson whose revised text would duplicate or contradict another memory keeps its text,
as does one already flagged conflicted. In an org whose model calls are switched off
the pass revises nothing, since a revision embeds the new text; it takes the lessons up
once the calls are back on. To keep a lesson’s wording as written, pin or lock it: a
hold that lands while the pass runs is read again before the revision is written.
For every other lesson, namespace.validate lists what a rewrite would be:
- Call
namespace.validateon the memory namespace (withkeysto check the lessons one session wrote) and read thecode_rename_editsfinding. Each sample is one lesson with eithereditsand acontent_sha256, or areason. - For a lesson with
edits,startandendcount Unicode code points of its text (a Python string index; not the UTF-16 units of a JavaScript string, nor bytes). Check that the text fromstarttoendreadsold, and apply nothing when it does not: the positions were counted in another unit. Then replace it withnew, applying the last edit first so the earlier positions hold. Read the edited sentence: an edit is offered on the spelling and the index, and whether the claim survives the swap is yours to judge. - Call
memory.updateon the key with the revised text andif_match_sha256set to the sample’scontent_sha256. A lesson that changed since the report returns409; run the report again. - After the next link pass the lesson is linked at the new name and reads
fresh, and the finding lists it no more.
A lesson with a reason gets no edit: the old name is a word of the prose, sits in a
quoted snippet, still names another definition, or the sentence is about the name itself
(every reason). Check it against the code
and rewrite it by hand.
The finding’s totals count a namespace’s lessons by edits and by reason: how often a
mechanical edit is offered there, and what stops the rest. A lesson listed with edits
in a repository indexed on more than one branch is for a person to read: its text can
name the code of one branch only.
The test_validate_lists_the_edit_a_followed_rename_allows_and_an_update_applies_it
integration regression
renames a function in a repository indexed on two branches, reads the listed edit,
applies it with memory.update and checks the link at the new name.
test_the_link_pass_revises_a_memorys_text_after_a_rename_on_a_one_branch_repository
does the same on one branch for a lesson of the code namespace and checks the text the
pass wrote, its history, that a pinned lesson keeps its text, and that a lesson of
another namespace keeps its text and is listed with its edit.
Compare a code-linked lesson across branches
When trunk and a maintained release branch diverge, a lesson can still apply to one of
them. Index both branches of the same repository in separate code namespaces
and run this check on a Loom host with local git mirrors (LOOM_GIT_HISTORY=local).
Use credentials that can read both code namespaces and the lesson.
-
Start with the same definition on both branches. Save a lesson about it and use
code.symbolin each code namespace. Pass the samelesson_namespaceslist when reading a separate memory namespace. Check that both responses include the same lesson and that itscode_stateisfresh. -
Push a commit to the indexed trunk and leave the release branch unchanged. After the index and link worker process that commit, read each branch again. Run either example from the original definition.
Change on trunk What to check on trunk What to check on the unchanged release branch Change an expression inside the function The lesson reads changed.The same lesson reads fresh.Rename a nonrecursive function without editing its body Look up the new name and check for moved.Look up the original name and check for fresh. -
Review the definition on the branch you are about to edit.
freshmeans the linked code still matches on that branch. Check that the lesson’s claim applies to the task before using it.
Some ops on this page are marked experimental on the status page.