Continual learning layer for coding agents and software projects.
Project description
Durable context for coding agents.
Turn coding-agent sessions into reusable context records. Capture decisions, constraints, preferences, and evidence so the next agent starts with precedent, not guesswork.
Website · Docs · PyPI · License
Works with Claude Code, Codex CLI, Cursor, and OpenCode.
Lerim
Lerim is a local-first context runtime for coding agents.
It watches agent sessions, extracts the durable parts, and stores them in one shared context layer that every future agent can query.
Instead of losing the reasoning after each session, Lerim keeps:
- decisions
- constraints
- preferences
- reference facts
- evidence linked back to the source session
Why Lerim
Coding agents are fast, but they forget.
Without a durable context layer:
- decisions get re-debated
- constraints get rediscovered
- preferences get ignored
- every new session starts too close to zero
Lerim fixes that by turning raw traces into reusable context records and making them queryable from the CLI, Lerim Cloud, and agent tools.
Key Capabilities
- Local-first storage. Durable context lives in one global SQLite database at
~/.lerim/context.sqlite3. - Shared across agents. What Claude Code learns can be reused by Codex, Cursor, or another supported agent later.
- Background maintenance.
syncingests sessions,maintainconsolidates overlap and archives stale records,askretrieves relevant precedent. - Hybrid retrieval. Lerim combines local ONNX embeddings stored through
sqlite-vecwith SQLite FTS5 and RRF fusion. - Clean agent tool surface. The runtime exposes semantic DB-era tools like
list_context,search_context,get_context,save_context,revise_context, andcount_contextinstead of file CRUD.
Quick Start
Install Lerim:
pip install lerim
Initialize and register the current repo:
lerim init
lerim connect auto
lerim project add .
Start the service:
lerim up
Check status:
lerim status
lerim status --live
Ask a question:
lerim ask "What do we already know about the auth flow?"
What the Commands Do
lerim up
Starts Lerim in the background so it can watch your workflow and process context jobs.
lerim status
Shows service health and current status.
lerim status --live
Shows live status updates. This is useful for demos and for watching background extraction happen.
lerim sync
Indexes sessions and extracts durable context from recent work. When Lerim is running in the background, sync work is scheduled from your configured intervals.
lerim maintain
Improves context quality over time by merging duplicates, archiving weak records, and refreshing useful context. Background maintenance is also driven by configured intervals.
lerim ask
Lets you ask questions against accumulated project context.
lerim ask "Why did we choose SQLite for local metadata?"
Configuration
lerim init creates the default local configuration. You can override settings in:
~/.lerim/config.toml
API keys are read from environment variables, stored by default in:
~/.lerim/.env
Example .env:
MINIMAX_API_KEY=your-key
OPENROUTER_API_KEY=your-key
OPENAI_API_KEY=your-key
ZAI_API_KEY=your-key
Example provider config:
[roles.agent]
provider = "minimax"
model = "MiniMax-M2.7"
fallback_models = ["zai:glm-4.7"]
How It Works
Lerim has three main flows:
-
syncReads new traces/session metadata and extracts durable context records. -
maintainRefines existing records by merging overlap and retiring low-value stale records. -
askRetrieves relevant records and answers a question using the current context layer.
In practice, this means Lerim becomes the shared precedent store behind your agent workflows.
Semantic retrieval is local:
- ONNX model:
mixedbread-ai/mxbai-embed-xsmall-v1 - vector storage:
sqlite-vec - lexical retrieval: SQLite FTS5
- fusion:
RRF
Storage Model
Global Lerim state lives under ~/.lerim/:
context.sqlite3— canonical durable context storeindex/sessions.sqlite3— session catalog and queueworkspace/— sync and maintain run artifactscache/traces/— compacted agent trace cachemodels/embeddings/— local embedding model cachemodels/huggingface/— Hugging Face library cacheconfig.toml— user configplatforms.json— connected platform pathslogs/YYYY/MM/DD/— dated runtime logs (lerim.log,lerim.jsonl, andactivity.log)
Project registration only stores host paths in config.
Project separation happens inside the database by project_id.
There is no per-project durable store on disk.
Agent Tools
The agent-facing tool contract is intentionally small:
read_tracelist_contextsearch_contextget_contextsave_contextrevise_contextarchive_contextsupersede_contextcount_contextnote_trace_findingsprune_trace_reads
These are the authoritative runtime tool names. Keeping the surface DB-era and semantic makes the runtime easier to reason about and gives smaller future models a cleaner action space for training.
Common Commands
lerim status
lerim status --live
lerim logs --follow
lerim queue
lerim queue --failed
lerim sync
lerim maintain
lerim ask "What decisions exist about caching?"
Setup and management:
lerim connect auto
lerim project list
lerim project remove <name>
lerim skill install
Alternative to the background service:
lerim serve
Development
uv venv && source .venv/bin/activate
uv pip install -e '.[test]'
tests/run_tests.sh unit
tests/run_tests.sh smoke
tests/run_tests.sh integration
tests/run_tests.sh e2e
Before release, verify the affected path with the relevant suites:
tests/smoke/— quick real-LLM extract sanitytests/integration/— real extract, maintain, and semantic ask coveragetests/e2e/— full runtime-cycle checks over sync, maintain, and ask
Start here if you want to read the codebase:
- src/lerim/README.md
- src/lerim/skills/cli-reference.md
- docs/concepts/how-it-works.md
- docs/concepts/context-model.md
Contributing
Contributions are welcome.
Good starting points include:
- session adapters and adding more agents
- extraction quality
- context maintenance quality
- docs and demo examples
Helpful links:
- Contributing Guide
- Open issues
- Agent adapter examples:
src/lerim/adapters/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lerim-0.1.81.tar.gz.
File metadata
- Download URL: lerim-0.1.81.tar.gz
- Upload date:
- Size: 182.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3da9199d225b36ce38fca3b3fced7b34d333f95a78ae9af476241984d1e9d8a8
|
|
| MD5 |
03b26ec7c414d702ccf016d8893cae3c
|
|
| BLAKE2b-256 |
78aaff6e123f32b93d890f41e6f1db4074b94544fcb7128265eaebc94ca78cca
|
Provenance
The following attestation bundles were made for lerim-0.1.81.tar.gz:
Publisher:
publish.yml on lerim-dev/lerim-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lerim-0.1.81.tar.gz -
Subject digest:
3da9199d225b36ce38fca3b3fced7b34d333f95a78ae9af476241984d1e9d8a8 - Sigstore transparency entry: 1405237392
- Sigstore integration time:
-
Permalink:
lerim-dev/lerim-cli@ff9f8ee86c51c4af72b420a2432ca699265260c3 -
Branch / Tag:
refs/tags/v0.1.81 - Owner: https://github.com/lerim-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ff9f8ee86c51c4af72b420a2432ca699265260c3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file lerim-0.1.81-py3-none-any.whl.
File metadata
- Download URL: lerim-0.1.81-py3-none-any.whl
- Upload date:
- Size: 202.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62654c0dcdc629a20d7fc65fef0acfb39548eb3f0c59644ec18415c42b59c2b3
|
|
| MD5 |
321fecf01090e84734f95bdae633744f
|
|
| BLAKE2b-256 |
1d5e5c5a01cb416acbd04e1d7e61e652d89bd15bbdb8b7261bf7ed9148962352
|
Provenance
The following attestation bundles were made for lerim-0.1.81-py3-none-any.whl:
Publisher:
publish.yml on lerim-dev/lerim-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lerim-0.1.81-py3-none-any.whl -
Subject digest:
62654c0dcdc629a20d7fc65fef0acfb39548eb3f0c59644ec18415c42b59c2b3 - Sigstore transparency entry: 1405237404
- Sigstore integration time:
-
Permalink:
lerim-dev/lerim-cli@ff9f8ee86c51c4af72b420a2432ca699265260c3 -
Branch / Tag:
refs/tags/v0.1.81 - Owner: https://github.com/lerim-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ff9f8ee86c51c4af72b420a2432ca699265260c3 -
Trigger Event:
push
-
Statement type: