Mirror Neuron Documents

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

FolderPurposeMain validation
Membrane/mn-context-engineRust gRPC context engine.cargo test
Membrane/mn-context-engine-python-sdkPython SDK shell and utilities for the Rust engine.python3 -m pytest -q
Membrane/mn-context-auto-optimizerDeterministic graph/NLP context compression and optional model tooling.python3 -m pytest -q
Membrane/mn-context-auto-optimizer-benchmarkBenchmark 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 -q

Optional 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 -q

Inspect runtime capabilities:

mn-context-packer runtime-info

Compress 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 executor

Supported compression modes:

ModeUse
graph_nlpDeterministic graph and NLP compression with no model dependency.
llm_onlyModel-only compression; requires --model-dir or MN_CONTEXT_MODEL_DIR.
hybridGraph-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.yaml

Build 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 12

Notes

  • 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.

On this page