feat(hindsight): use explicit tag filters for auto-prefetch - #14620
feat(hindsight): use explicit tag filters for auto-prefetch#14620poruru-code wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an opt-in metadata scoping mechanism for Hindsight automatic prefetch recall so that recalled memories can be locally filtered to the current session’s stable identity metadata (reducing cross-session/bank leakage) without changing manual hindsight_recall behavior.
Changes:
- Introduces config keys
recall_prefetch_metadata_fieldsandrecall_prefetch_metadata_strict, including normalization/allowlisting and boolean parsing. - Builds an “active metadata scope” from provider session state and filters auto-prefetch recall results (with strict vs non-strict semantics, and a no-op when scope is empty).
- Adds focused unit tests and documents the new configuration in the Hindsight README.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
plugins/memory/hindsight/__init__.py |
Implements metadata field normalization, active scope construction, and local filtering for auto-prefetch recall results (ignored for reflect). |
tests/plugins/memory/test_hindsight_provider.py |
Adds normalization tests and comprehensive prefetch filtering behavior tests (strict/non-strict/empty-scope/reflect/manual-tool unaffected). |
plugins/memory/hindsight/README.md |
Documents the new auto-prefetch-only metadata scoping keys and their semantics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
nicoloboschi
left a comment
There was a problem hiding this comment.
for filtering you must use tags, not metadata
|
@nicoloboschi The metadata-based post-filtering path is gone. Auto-prefetch now uses:
When these are set, they apply only to auto-prefetch. When they are unset, auto-prefetch falls back to the existing recall_tags / recall_tags_match behavior. I intentionally kept the scope narrow:
I also updated the targeted tests and docs, and validated the resulting behavior against a real Hindsight Cloud bank. |
|
Thanks for narrowing this to request-side tag filtering after the earlier review. Current main still applies The current schema also has no prefetch-specific tag fields ( This is an automated hermes-sweeper review. |
Summary
Add explicit tag filters for Hindsight automatic prefetch recall.
This changes auto-prefetch to use request-side tag filters instead of the earlier metadata-based filtering approach, aligning the implementation with the intended filtering surface.
Related
Changes
recall_prefetch_tagsrecall_prefetch_tags_matchrecall_prefetch_tags/recall_prefetch_tags_matchwhen configuredrecall_tags/recall_tags_matchwhen prefetch-specific tags are unsethindsight_recallunchangedhindsight_retainunchangedBehavior
recall_prefetch_tagsonly affects automatic prefetch recallrecall_tagsreflectmode remains unchangedNotes
This PR is intentionally narrow:
recall_prefetch_tagsonly matches memories that already carry those tags. It does not backfill old memories, infer tags from metadata, or change retain behavior.For strict scoping, use
_stricttag match modes, since non-strictany/allmodes may still include untagged memories.Testing
Passed:
uv run scripts/run_tests.sh tests/plugins/memory/test_hindsight_provider.pyuv run scripts/run_tests.sh tests/agent/test_memory_user_id.pyAlso validated against a real Hindsight Cloud bank:
recall_prefetch_tagshindsight_recallremains governed by genericrecall_tagsrecall_tagswhen prefetch-specific tags are unset