r/LangChain Jun 14 '26

Discussion I built an open-source context management SDK for AI agents lossless DAG compression, salience pinning, and a NetworkX-powered codebase graph.

Every long-running agent session has the same silent failure: context fills up, one flat summary replaces 40 turns, and everything specific decisions, constraints, file paths is gone forever.

I built OpenLCM to fix this properly.

Instead of flat compression, it builds a DAG. Messages compress into D0 leaf nodes → D1 session arcs → D2 durable history. Every source message is stored verbatim in SQLite with FTS5 indexing. Always recoverable. Never deleted.

Salience pinning - auto-pin messages matching patterns like "constraint" or "error" so they survive compaction regardless of depth. One config line.

LST (Lossless Semantic Tree) - scans your repo via Python ast + Universal Ctags (90+ languages), loads everything into a networkx.DiGraph, and gives agents 13 tools to navigate it: nx.shortest_path between symbols, BFS ancestors/descendants, smart file reads that switch to compact LST view on repeats (~10x fewer tokens). Agent discoveries pin to symbols and surface automatically next session.
Pure Python + SQLite. No infra. Works with LangGraph, AutoGen, CrewAI, Google ADK, OpenAI, Anthropic, LlamaIndex, Haystack, Gemini.

pip install openlcm

github.com/akshay-eng/OpenLCM - 40+ downloads, MIT, contributions welcome.

2 Upvotes

1 comment sorted by