Skip to content

fix: honor memory scope filters during recall - #16

Merged
haolpku merged 1 commit into
OpenDCAI:mainfrom
DevChiniwala:codex/fix-memory-scope-filter
Sep 20, 2026
Merged

haolpku merged 1 commit into
OpenDCAI:mainfrom
DevChiniwala:codex/fix-memory-scope-filter

Conversation

@DevChiniwala

Copy link
Copy Markdown
Contributor

Summary

memory_recall accepts scope_filter to limit which memory scopes contribute, but the filter could be bypassed by MemoryService default-profile fallback.

When a caller requested global-only recall, the tool cleared the profile before calling the service. MemoryService.recall() then replaced the falsey profile with its default profile, returning profile-scoped evidence that the caller explicitly excluded.

Fix

  • Thread scope_filter through the memory tool to MemoryService.recall().
  • Apply the filter before default-profile fallback so excluded profile/session scopes remain excluded.
  • Add a deterministic SQLite regression covering global, profile, and session memories through the public memory_recall tool handler.

No storage schema, response shape, or provider API changes.

Validation

  • Regression: passes after the fix; fails before it with 2 results instead of 1.
  • Memory tests: 18 passed.
  • Full offline pytest: 226 passed, 5 skipped.
  • python -m compileall -q datamind: passed.
  • SQLite verification demo: passed.
  • No paid or live LLM APIs used.

The five skipped tests are optional claude_agent_sdk hook tests.

Copilot AI lite review requested due to automatic review settings September 17, 2026 10:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@haolpku haolpku left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Requesting changes because the implementation does not fully honor scope_filter. MemoryService only clears profile/session IDs; the SQLite store still includes global memories unconditionally. Therefore scope_filter=['profile'] and ['session'] can still return global items, and [] falls back to all scopes. Please carry an explicit allowed-scope set through the service/store (or filter before returning), define the empty-list behavior, and add tests for global-only, profile-only, session-only, combinations, and empty input.

@haolpku
haolpku merged commit 87a55f8 into OpenDCAI:main Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants