Feat: make mnemon plugin content caps configurable - #11
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes the Mnemon Hermes memory provider’s content truncation limits configurable and raises the default mirror truncation ceiling to align with the mnemon CLI’s apparent 8000-character limit.
Changes:
- Added
max_compress_charsandmax_mirror_charsto the provider config schema and load them frommnemon.jsonduring initialization. - Updated
on_pre_compressandon_memory_writeto use configurable caps (and added a truncation warning for mirror writes). - Updated the config schema test to account for the two new keys.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
mnemon/__init__.py |
Introduces configurable character caps for pre-compress storage and memory-write mirroring; increases default mirror cap and adds a truncation warning. |
tests/test_mnemon.py |
Updates config schema assertions for the new configuration keys. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
316
to
321
| def on_pre_compress(self, messages: list[dict]) -> str: | ||
| key_msgs = [m for m in messages if m.get("role") in ("assistant","user") | ||
| and len(m.get("content","")) > 80][-10:] | ||
| for msg in key_msgs: | ||
| self._remember_and_index(msg["content"][: 600], | ||
| self._remember_and_index(msg["content"][: self._max_compress_chars], | ||
| category="context", importance=2) |
Comment on lines
160
to
+180
| # Load store config if it exists | ||
| store_config = None | ||
| if hermes_home: | ||
| config_file = Path(hermes_home) / "mnemon.json" | ||
| if config_file.exists(): | ||
| try: | ||
| config_data = json.loads(config_file.read_text()) | ||
| store_config = config_data.get("store") | ||
| except Exception as e: | ||
| logger.warning("Failed to load mnemon.json: %s", e) | ||
|
|
||
| # Load plugin-specific config (max_compress_chars, max_mirror_chars) | ||
| max_compress_chars = 600 | ||
| max_mirror_chars = 8000 | ||
| if hermes_home: | ||
| config_file = Path(hermes_home) / "mnemon.json" | ||
| if config_file.exists(): | ||
| try: | ||
| plugin_data = json.loads(config_file.read_text()) | ||
| max_compress_chars = int(plugin_data.get("max_compress_chars", 600)) | ||
| max_mirror_chars = int(plugin_data.get("max_mirror_chars", 8000)) |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feat: make mnemon plugin content caps configurable; raise mirror ceiling to 8000
Problem
The
mnemonHermes plugin had two hardcoded character caps that were unnecessarilyconservative — both below the
mnemonbinary's owncontent too long (max 8000)error message:
mnemonbinary ceilingon_pre_compresson_memory_writeOther Hermes memory plugins (Mem0, RetainDB, Hindsight, Honcho) either send raw
content or rely on their backends for chunking — Mnemon was the only plugin with
redundant content truncation that had nothing to do with any actual constraint.
Users who wanted to store longer insights were silently losing information with
no way to opt in.
Design rationale: why the limits differ from the binary ceiling
on_pre_compress— kept at 600 (configurable, not the binary ceiling)The
on_pre_compresshook fires at the end of every turn and stores the last 10substantive messages as individual graph nodes under category
context. Its purposeis to be a compression breadcrumb trail — lightweight, scannable after-images of
recent exchanges — so recall can still surface relevant context after the full
conversation window has been compacted.
600 chars ≈ 3–4 sentences. For this hook that is a feature, not a bug:
summary scores better against user queries than a 1 500-char chunk that averages
away edge-case semantics.
remembercall creates a node with edges. Morenodes from the same turn = more edges = marginally higher traversal cost per
recall call.
cheap and predictable regardless of turn length.
on_pre_compresscall. Investing 4 000 chars per turn for content that will bereplaced next turn is wasted graph storage.
The
mnemonbinary's 8 000-char ceiling is an upper bound for a persistent nodethat represents a lasting insight — exactly what
on_memory_writecaptures. The600-char cap for the transient compression hook reflects the different lifetime
semantics, not a technical mismatch.
on_memory_write— default 8000 to match the binary ceilingThese are intentional, persistent memory writes (user preferences, decisions,
factual claims). They benefit from being as complete as the binary will accept. The
previous 2 500-char cap was a defensive guardrail from early prototyping that was
never revisited once the binary's own error path was confirmed. Setting it to 8000
removes that redundant truncation while keeping the plugin-level cap configurable so
users can opt lower if needed. Setting it to
0removes it entirely and lets thebinary's own error become the sole gate.
30-char minimum — hard skip, not configurable
No memory plugin in the Hermes ecosystem (Mnemon, Honcho, Mem0, RetainDB,
Hindsight, Holographic, SuperMemory) makes the minimum content length configurable.
Single-word or two-word utterances (
"ok","sure","done") carry negligiblesignal and everyone agrees filtering them out is a quality gate, not a usability
restriction. It stays hardcoded.
Changes
mnemon/__init__.py1. Config schema — two new keys (
get_config_schema){ "key": "max_compress_chars", "default": 600, ... }, { "key": "max_mirror_chars", "default": 8000, ... },2.
initialize()— load new keys from~/.hermes/mnemon.json3.
on_pre_compress()— useself._max_compress_charsinstead of literal6004.
on_memory_write()— replace literal2500with configured cap + warning5.
_auto_remember()— documentation-only changeAdded an inline comment explaining the 30-char noise filter. Behaviour unchanged.
tests/test_mnemon.pytest_get_config_schema— updated assertion fromlen(schema) == 1to== 3and added explicit key checks for the two new entries.
Default values (backwards compatible)
max_compress_chars600max_mirror_chars8000mnemonbinary ceilingConfiguration
Users override in
~/.hermes/mnemon.json(same file as the existingstorekey):{ "store": "my-store", "max_compress_chars": 1200, "max_mirror_chars": 0 }Verification
Files changed
mnemon/__init__.py— +43 −6tests/test_mnemon.py— +4 −1