Context Memory And Compression
Documentation for Context Memory And Compression.
Context Memory And Compression
MirrorNeuron uses the Membrane projects for shared working memory, context selection, context compression, and benchmark evaluation.
Components
| Folder | Purpose | Main validation |
|---|---|---|
Membrane/mn-context-engine | Rust gRPC context engine. | cargo test |
Membrane/mn-context-engine-python-sdk | Python SDK shell and utilities for the Rust engine. | python3 -m pytest -q |
Membrane/mn-context-auto-optimizer | Deterministic graph/NLP context compression and optional model tooling. | python3 -m pytest -q |
Membrane/mn-context-auto-optimizer-benchmark | Benchmark and telemetry package for context compression models. | python3 -m pytest -q |
Python SDK
Install the Membrane Python SDK from source:
cd Membrane/mn-context-engine-python-sdk
python3 -m pip install -e ".[dev]"
python3 -m pytest -qOptional extras are package-specific:
python3 -m pip install -e ".[compression]"
python3 -m pip install -e ".[qdrant]"Use qdrant and qdrant-gpu in separate environments because their FastEmbed
dependencies are mutually exclusive.
Optimizer Runtime
Install the deterministic optimizer:
cd Membrane/mn-context-auto-optimizer
python3 -m pip install -e ".[dev]"
python3 -m pytest -qInspect runtime capabilities:
mn-context-packer runtime-infoCompress a context packet from standard input:
cat packet.json | mn-context-packer compress \
--compression-mode graph_nlp \
--target-tokens 800 \
--focus-id goal_1 \
--agent-role executorSupported compression modes:
| Mode | Use |
|---|---|
graph_nlp | Deterministic graph and NLP compression with no model dependency. |
llm_only | Model-only compression; requires --model-dir or MN_CONTEXT_MODEL_DIR. |
hybrid | Graph-first deterministic compression with optional evidence-only rewrite. |
Benchmarks
Install the benchmark package:
cd Membrane/mn-context-auto-optimizer-benchmark
python3 -m pip install -e ".[dev]"Run the default graph benchmark:
mn-context-benchmark --config configs/default.yamlBuild a blueprint-derived benchmark suite from the local catalog:
mn-context-build-blueprint-suite \
--blueprint-root ../../mn-blueprints \
--packet-output artifacts/data/blueprint_packet_results.json \
--working-memory-output artifacts/data/blueprint_working_memory_cases.json \
--coverage-output artifacts/data/blueprint_suite_coverage.json \
--cases-per-manifest 12Notes
- The deterministic runtime path should preserve goals, constraints, source references, failures, recovery state, and next actions.
- Optional model or GPU dependencies should be installed only for the benchmark or compression path that needs them.
- Keep private or role-restricted memory out of shared context packets unless the caller explicitly has access.