Skip to content

enhancement: Session memory grows unbounded — add eviction and chat history cap #76

Description

@QuantumByte-01

Problem

NeuroscienceAssistant stores session data in two in-memory dicts:

self.chat_history: Dict[str, List[str]] = {}
self.session_memory: Dict[str, Dict[str, Any]] = {}

session_memory stores full search result payloads (up to 60 results per session) and is never evicted. On a long-running server with many users this will grow until the process runs out of memory.

chat_history caps at 20 entries per session but sessions themselves are never removed.

Solution

  • Add a max session count (e.g. 1000) with LRU eviction using collections.OrderedDict
  • Add a session TTL (e.g. evict sessions inactive for >1 hour)
  • Document memory behaviour in the README

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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