Skip to content

[Bug]: MemoryProvider.on_pre_compress() return value silently discarded — provider insights never reach the compressor #7192

@Tranquil-Flow

Description

@Tranquil-Flow

Bug Description

run_agent.py line 6081 calls self._memory_manager.on_pre_compress(messages) as a bare statement, discarding the return value. The memory_manager.on_pre_compress() method correctly collects text from all providers and returns it as a combined string (joined with "\n\n"), but this text is never passed to the compressor.

Additionally, context_compressor.compress() and _generate_summary() have no parameter to accept memory provider context, so even capturing the return value has nowhere to go without updating those signatures.

This affects all MemoryProvider plugins (Honcho, Holographic, Mem0, Supermemory, RetainDB, and any third-party plugins).

Steps to Reproduce

  1. Implement a MemoryProvider that returns non-empty text from on_pre_compress()
  2. Trigger context compression (long conversation or /compress)
  3. Observe via DEBUG logging that the provider's on_pre_compress() returns text
  4. Observe that the returned text never appears in the compression summary

Expected Behavior

Text returned by MemoryProvider.on_pre_compress() should be injected into the compression summary prompt so the compressor preserves provider-extracted insights (as documented in the ABC docstring and memory_manager.on_pre_compress() return-value docstring).

Actual Behavior

The return value is silently discarded. The hook only works as a notification (observe messages before they're discarded), not as the injection point it was designed to be.

Affected Component

Agent Core (conversation loop, context compression, memory)

Messaging Platform (if gateway-related)

N/A (CLI only)

Operating System

macOS 15.6.1

Python Version

3.11.14

Hermes Version

v0.8.0

Root Cause Analysis (optional)

Three-part gap:

  1. Call site (run_agent.py line 6081): self._memory_manager.on_pre_compress(messages) is called as a statement — the return value is not captured.
  2. compress() signature (agent/context_compressor.py line 612): compress(self, messages, current_tokens=None) has no parameter to accept memory context.
  3. _generate_summary() (agent/context_compressor.py line 287): No mechanism to inject provider insights into the summarization template.

The dispatch layer (memory_manager.py lines 290-307) is correct — it collects provider contributions and returns a combined string. The bug is entirely at the caller and consumer level.

Proposed Fix (optional)

  1. Capture the return value in run_agent.py
  2. Add memory_context: str = "" parameter to compress() and _generate_summary()
  3. Inject a "MEMORY PROVIDER INSIGHTS" section into the summarization prompt when non-empty

PR incoming.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/agentCore agent loop, run_agent.py, prompt buildercomp/pluginsPlugin system and bundled pluginstool/memoryMemory tool and memory providerstype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions