Skip to content

fix(memory): enforce Hindsight routes across recall, reflect, and retain - #40947

Open
jackroofan wants to merge 1 commit into
NousResearch:mainfrom
jackroofan:fix/hindsight-recall-routing
Open

fix(memory): enforce Hindsight routes across recall, reflect, and retain#40947
jackroofan wants to merge 1 commit into
NousResearch:mainfrom
jackroofan:fix/hindsight-recall-routing

Conversation

@jackroofan

@jackroofan jackroofan commented Jun 7, 2026

Copy link
Copy Markdown

Summary

  • select one Hindsight route from conversation context and apply it consistently to automatic recall, explicit hindsight_recall, hindsight_reflect, and retain tagging
  • enforce deterministic selection: exact chat_ids > exact case-insensitive chat_names > case-insensitive keywords in the query/chat name; same-signal ties use configuration order
  • keep route filtering effective across clients with and without tag_groups, including exclusions, priority-first recall, deduplication, result caps, and one bounded type-broadening fallback
  • make reflect honor recall_max_tokens, use routed filters, and fall back to routed recall when synthesis/tag-group support cannot provide an answer
  • optionally suppress short low-signal recall while allowing configured domain keywords through

Configuration contract

recall_routes accepts either a JSON object or the JSON string emitted by the plugin config UI. A non-empty object enables routing. Each ordered named route may contain:

  • selectors: chat_ids, chat_names, keywords
  • recall filters: tags, tags_match, exclude_tags, query_prefix
  • priority pass: priority_tags, priority_tags_match, priority_query_prefix
  • fallback/result controls: min_results, max_results
  • retain behavior: retain_tags

Global optional controls are:

  • recall_max_results (0 means unlimited; a route can override it)
  • recall_skip_low_signal_queries
  • recall_low_signal_min_chars
  • recall_domain_signal_keywords

Existing configs remain unchanged when these settings are absent. If no route matches, existing global recall_tags / recall_tags_match behavior is preserved.

Behavior and fallback

  • Positive and negative route filters are sent as tag_groups when supported.
  • If the client rejects tag_groups, recall retries with positive tags and applies priority/exclusion checks client-side.
  • priority_tags results are fetched first, merged without duplicates, then capped.
  • min_results permits one retry without the configured type restriction while retaining the same route filters.
  • Reflect uses the same route filters; unsupported routed reflect or an explicit no-information response falls back to formatted routed recall.
  • retain_tags are merged after global retain tags and before per-call tags.
  • Low-signal suppression is opt-in and applies to both automatic prefetch and explicit recall; configured signal keywords bypass it.

Scope

This refresh is rebuilt from current origin/main and contains only:

  • plugins/memory/hindsight/__init__.py
  • tests/plugins/memory/test_hindsight_provider.py

It intentionally excludes Task Scope work, host-specific configuration/data, gateway changes, deployment scripts, and other product changes.

Tests

  • HERMES_HOME=<temp> python -m pytest tests/plugins/memory/test_hindsight_provider.py -q -o 'addopts='137 passed
  • python -m ruff check plugins/memory/hindsight/__init__.py tests/plugins/memory/test_hindsight_provider.pypassed
  • python -m py_compile plugins/memory/hindsight/__init__.py tests/plugins/memory/test_hindsight_provider.pypassed
  • git diff --check origin/main...HEADpassed

Coverage includes configuration parsing/schema exposure, signal precedence and config-order ties, no-match global fallback, prefetch routing before query truncation, positive/negative filters, fallback filtering, priority ordering, caps, bounded type broadening, reflect fallback, retain tagging, low-signal suppression, and safe service failure.

Risk

Mostly opt-in: route, retain, priority, fallback, cap, and low-signal behavior activate only when configured. The non-route reflect path now also passes the existing recall_max_tokens value to Hindsight so reflect and recall share the configured token ceiling.

@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 labels Jun 7, 2026
@jackroofan
jackroofan force-pushed the fix/hindsight-recall-routing branch from 057fa88 to ee905c2 Compare June 7, 2026 16:42
@jackroofan
jackroofan force-pushed the fix/hindsight-recall-routing branch from ee905c2 to 563fc07 Compare July 10, 2026 17:24
@jackroofan jackroofan changed the title fix: route Hindsight recall by context signals fix(memory): route Hindsight recall by context signals Jul 10, 2026
@teknium1 teknium1 added sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users area/memory Memory subsystem: store, providers, sync, background reviews labels Jul 14, 2026
@jackroofan
jackroofan force-pushed the fix/hindsight-recall-routing branch from 563fc07 to 5e13b23 Compare July 21, 2026 11:55
@jackroofan jackroofan changed the title fix(memory): route Hindsight recall by context signals fix(memory): enforce Hindsight routes across recall, reflect, and retain Jul 21, 2026
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/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data 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.

3 participants