hermes - 💡(How to fix) Fix [Feature]: Tiered Memory Injection (`memory_tiers`)

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Code Example

memory:
  provider: holographic
  memory_tiers:
    - char_limit: 2200
      match: "*"                    # fallback — applies to all models
    - char_limit: 8000
      match: "context>=1000000"     # only models with ≥1M context window
    - char_limit: 5000
      match: "context>=200000"      # mid-tier

---

memory_tiers:
  - char_limit: 10000
    match: "context>=500000"
  - char_limit: 2200
    match: "*"

---
RAW_BUFFERClick to expand / collapse

Problem or Use Case

Currently, memory injection uses a single memory_char_limit (default 2200) for all models. This creates a tension:

  • Small models (32K context): need a tight limit to avoid eating into working context
  • Large models (1M context): wastefully restricted — could hold 5–10× more persistent facts

The user must choose one limit, compromising either small-model safety or large-model capability.

Proposed Solution

Add memory_tiers as an alternative to memory_char_limit. Each tier specifies a char limit and a model filter:

memory:
  provider: holographic
  memory_tiers:
    - char_limit: 2200
      match: "*"                    # fallback — applies to all models
    - char_limit: 8000
      match: "context>=1000000"     # only models with ≥1M context window
    - char_limit: 5000
      match: "context>=200000"      # mid-tier

Match criteria (one or more):

  • context>=N — model's configured context_length is at least N tokens
  • model — glob pattern on model name (e.g. claude*, *sonnet*)
  • provider — provider name match
  • "*" — catch-all fallback (must be last tier)

Resolution: first matching tier wins. If no memory_tiers configured, fall back to existing memory_char_limit.

Use Case

A user with DeepSeek V4 (1M context) and an occasional fallback to a 32K model:

memory_tiers:
  - char_limit: 10000
    match: "context>=500000"
  - char_limit: 2200
    match: "*"

Large model sessions get rich persistent memory. Small model sessions stay safe.

Implementation Notes

  • Injection logic in agent/memory/ — replace flat memory_char_limit truncation with tier-aware truncation
  • context_length is already available from model config
  • Backward compatible: absence of memory_tiers → use memory_char_limit
  • Config migration: hermes config migrate should NOT auto-convert to tiers

Alternatives Considered

  1. Just bump memory_char_limit — works for large-model-only users, doesn't solve the multi-model case
  2. Profile-based limits — separate profiles for different models, but splits memory state across profiles
  3. Dynamic injection — inject more memory when compression is about to trigger. Complex, unpredictable.

Tiered injection is simple, predictable, and solves the problem at the config level.

Alternatives Considered

No response

Feature Type

Configuration option

Scope

None

Contribution

  • I'd like to implement this myself and submit a PR

Debug Report (optional)

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix [Feature]: Tiered Memory Injection (`memory_tiers`)