Skip to content

Implement persistent user long-term memory with query-context injection #470

Description

@AlbertCorry

Summary

NLWeb's Memory pre-check (AskAgent/python/core/query_analysis/memory.py) can detect when a user asks to be remembered, but it only emits a transient remember message. There is no durable per-user storage, and stored memories are not injected into later query context.

Expected behavior

  • When the Memory pre-check detects a remember request, persist the memory for the user (oauth_id or user_id).
  • On later queries, prepend stored memories to prev_queries as [memory] {text}.
  • Re-enable the Memory pre-check in handler preparation when memory_enabled is true.
  • Expose REST endpoints to list and delete user memories:
    • GET /user/memory?user_id=...
    • DELETE /user/memory/{memory_id}?user_id=...
  • Support memory_mock=true for offline/testing without LLM calls.

Context

  • docs/nlweb-memory.md describes long-term memory as a hook, not a full implementation.
  • memory.py line 43: # this is where we would write to a database
  • Memory step is commented out in baseHandler.prepare().

Commit reference

b423f15d9aeaa023ce75993ac9deed2354597043

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions