agentleFS
lauren-frameworklauren-framework/lauren-ai/skills/managing-memory/SKILL.md

managing-memory

Skill0 starsChanged 6 months agoMITView on GitHub

Manages memory tiers in lauren-ai agents — short-term rolling window, conversation history, user memory facts with @remember, and vector store for RAG. Use when adding persistent memory to an agent, implementing @remember() for long-term facts, using ConversationStore across sessions, or building RAG with InMemoryVectorStore.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use ConversationStore to persist full message history across multiple agent runs within a session.

    line 75

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Use codemap find "SymbolName" to locate any symbol before reading — it gives exact file + line range and is faster than grep across the whole repo.

Managing Memory in Agents

Memory tier overview

TierClassScopePersistenceManaged by
1. Short-termShortTermMemorySingle agent runNone — resets each runAgentRunner (automatic)
2. ConversationConversationStore / InMemoryConversationStoreSession (conversation ID)In-memory or custom backendApplication
3. User memoryUserMemoryStore / InMemoryUserMemoryStore + @rememberPer user (user ID)In-memory or custom backend@remember decorator
4. VectorInMemoryVectorStoreApplication-wideIn-memoryApplication

Quick start: @remember for long-term user facts

from lauren_ai import (
    agent, remember, use_guardrails, use_tools,
    InMemoryUserMemoryStore, PromptInjectionFilter,
)

_memory = InMemoryUserMemoryStore()

@agent(model="claude-opus-4-6", system="You are a personal assistant.")
@remember(store=_memory, extract=True, inject=True, top_k=5)
@use_guardrails(input=[PromptInjectionFilter()])
@use_tools(my_tool)
class PersonalAssistant: ...

How it works:

  1. Inject (inject=True): Before each LLM call, top_k relevant facts are retrieved from the store and prepended to the system prompt as:
    ## What I remember about you:
    - User prefers dark mode (confidence: high)
    - User works on Python projects (confidence: medium)
  2. Extract (extract=True): After each conversation turn, the LLM extracts new facts from the exchange and stores them.

Decorator order (mandatory)

@remember() must sit between @agent() and @use_guardrails():

@agent(model="claude-opus-4-6")   # outermost — applied last
@remember(store=_memory, ...)      # reads/sets REMEMBER_META
@use_guardrails(input=[...])       # optional
@use_tools(my_tool)                # innermost — applied first
class MyAgent: ...

Python applies decorators bottom-up. Wrong ordering causes the decorator that reads metadata to run before the decorator that writes it, silently dropping tools, guardrails, or memory configuration.


Tier 2: Conversation history across runs

Use ConversationStore to persist full message history across multiple agent runs within a session. Declare it on the agent (or override it per call):

from lauren_ai import agent, InMemoryConversationStore

store = InMemoryConversationStore()

@agent(model="claude-opus-4-6", conversation_store=store)
class MyAgent: ...

Then pass a conversation_id on each run() call — the runner loads prior history before the new message and saves afterward:

# Turn 1
result1 = await runner.run(agent, "My name is Alice.", conversation_id="sess-1")
# Turn 2 — agent sees the full prior exchange
result2 = await runner.run(agent, "What is my name?", conversation_id="sess-1")
# result2.content → "Your name is Alice."

Without conversation_store, conversation_id is accepted but ignored.


Tier 4: Vector store for RAG

from lauren_ai import InMemoryVectorStore

store = InMemoryVectorStore()

# Index documents (requires EmbedService)
await store.add(
    texts=["Python is a programming language.", "FastAPI is an async web framework."],
    embed_service=embed_service,
)

# Query
results = await store.search(
    query="web development with Python",
    embed_service=embed_service,
    top_k=3,
)
for doc, score in results:
    print(f"{score:.3f} — {doc}")

Reference

See memory.md for:

  • Full ShortTermMemory API (including ctx.memory access from lifecycle hooks)
  • ConversationStore protocol and implementing a custom persistent backend
  • @remember parameters (store, extract, inject, top_k, store_token)
  • Manual store.add() / store.search() usage with MemoryFact
  • Implementing a custom UserMemoryStore (e.g. Postgres-backed)
  • InMemoryVectorStore full API
  • TeamMemory shared state for multi-agent teams

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.