Skip to content

fix: bound memory capture and recall output - #21692

Open
xdeepsnyx wants to merge 1 commit into
NousResearch:mainfrom
xdeepsnyx:fix/memory-capture-recall-bounds
Open

fix: bound memory capture and recall output#21692
xdeepsnyx wants to merge 1 commit into
NousResearch:mainfrom
xdeepsnyx:fix/memory-capture-recall-bounds

Conversation

@xdeepsnyx

Copy link
Copy Markdown

Summary

  • Preserve explicit Supermemory capture mode and prevent auto/session-end ingestion when automatic capture is disabled.
  • Harden Supermemory explicit writes with safe metadata and bound profile output to visible result counts.
  • Add a shared memory/search output cap and apply it to session search and provider-backed memory search/profile tools.

Motivation

Provider-backed memory can become counterproductive if automatic capture ignores conservative settings or if recall/search payloads grow large enough to flood active context. This PR keeps curated memory useful while bounding automatic ingestion and recall output.

Changes

  • memory.auto_capture: false now gates Supermemory on_session_end ingestion.
  • capture_mode: explicit is preserved by config normalization and skips automatic turn capture.
  • Explicit Supermemory writes add non-sensitive metadata such as saved_at, platform, and origin where available.
  • Supermemory profile output is limited to the configured recall count while still returning total counts and a truncated flag.
  • Adds memory.search_result_char_limit with a default of 10,000 characters.
  • Adds tools.memory_search_caps to cap memory/search-style tool results with a visible truncation notice.
  • Applies the cap to session_search and memory-provider search/profile/recall-like tools.

Test plan

env -u SUPERMEMORY_CONTAINER_TAG \
    -u SUPERMEMORY_CUSTOM_CONTAINERS \
    -u SUPERMEMORY_ENABLE_CUSTOM_CONTAINER_TAGS \
    python -m pytest \
      tests/plugins/memory/test_supermemory_provider.py \
      tests/tools/test_session_search.py \
      -o 'addopts=' -q

Result: 72 passed in 1.85s

Closes #21690

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins tool/memory Memory tool and memory providers comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint labels May 8, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing both Supermemory capture controls and recall growth.

Problems

  • capture_mode: explicit is preserved and skips sync_turn, but the changed on_session_end() guard only adds _auto_capture; with auto_capture=true, explicit mode still calls ingest_conversation() automatically (plugins/memory/supermemory/__init__.py, changed session-end guard; current equivalent at :720-744).
  • The new session_search cap is applied only to browse/discovery returns. Current routing returns _scroll() and _read_session() directly (tools/session_search_tool.py:678-739), leaving those message-bearing paths unbounded.
  • The session-search test is based on _summarize_session, which current main no longer contains; current main uses the four-shape dispatcher at tools/session_search_tool.py:619-740.

Suggested changes

  • Apply one automatic-capture predicate, including explicit mode, to every automatic ingest path and test session-end behavior.
  • Bound all four session-search shapes using valid structured output and truncation metadata, then test oversized read and scroll results.

Automated hermes-sweeper review.

@@ -593,7 +601,7 @@ def _run():
self._sync_thread.start()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This guard still permits automatic session-end ingest when capture_mode == "explicit" and auto_capture is true. If explicit means explicit writes only, include that mode here as well and add a session-end regression test.

@@ -265,6 +266,10 @@ async def _summarize_session(
_HIDDEN_SESSION_SOURCES = ("tool",)


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This helper is only used for browse/discovery returns in this patch; the scroll and read shapes still return unbounded payloads. Apply the boundary policy to every session_search shape and preserve valid structured output after truncation.

@teknium1 teknium1 added sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-broad Sweeper blast radius: broad — a core path most sessions hit area/memory Memory subsystem: store, providers, sync, background reviews labels Jul 13, 2026
jkobject added a commit to jkobject/hermes-agent that referenced this pull request Jul 21, 2026
Prevent every automatic session-ingest boundary from uploading content when auto_capture is false, while leaving explicit memory writes available.

Carries the privacy behavior from installed commit 6830f77 and the independently proposed guard in NousResearch#21692.

Co-authored-by: Nyx <nyx@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/memory Memory subsystem: store, providers, sync, background reviews comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have sweeper:blast-broad Sweeper blast radius: broad — a core path most sessions hit sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state tool/memory Memory tool and memory providers type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Harden memory capture and recall bounds for Supermemory/provider-backed memory

4 participants