Discourse AI persistent memory

I appreciate the development on Discourse AI which has been excellent. The features are maturing quickly, and the direction looks very promising.

One question: is there currently a way, or any roadmap plans, for the AI to retain history between chats? At the moment each conversation starts fresh, and I’m wondering if persistent memory or continuity between sessions is being considered.

If it’s not already on the roadmap, I’d like to raise it as a feature request. Having the option for AI to remember past interactions would make discussions more natural and significantly expand use cases.

2 Likes

I implemented a basic key/value store using a persona and custom tools on my blog.

That said, this is very hard to get right, you got to keep nudging personas to remember stuff which is annoying.

The alternative is to just use RAG over all of your history with the bot (somewhat similar to how Open AI does this)


I guess for starters, what is your vision on how this would work? How would it improve things?

1 Like

I’m really thinking about the end-user continuity experience, RAG I consider great for admins to provide info for persona. With ChatGPT/Gemini/others, the bot carries a small profile forward—tone, depth, ongoing goals—so you don’t have to re-explain each session. That’s the experience that would be great in Discourse AI: the assistant remembers a few durable things about each user and uses them when relevant, so conversations pick up where they left off.

I have no understanding if end user RAG history for conversations is possible in any way.

The value is that any reliable “it knows me” feel without constant prompting greatly enhances the experience for use cases where the same type conversations are revisited by users.

That being said I don’t think any of this is a minor undertaking. I can’t say enough about how well all this has been developed already.

I managed to create a plugin and custom tool that enables persistent memory for Discourse AI personas. It’s working well from my limited testing, and I wanted to share if someone finds it helpful.

What It Does

This solution allows AI personas to remember user-specific information across conversations.

Example: a user can say “Remember that I prefer dark mode” and the AI will store and recall this preference in future interactions.

Components

This system has three parts:

  • Plugin (discourse-ai-persistent-memory)
    Provides backend storage and a user preferences UI where users can view, add, or delete their memories.
  • Custom AI Tool
    A JavaScript tool that gives personas access to memory functions:
    memory.set, memory.get, memory.list, memory.delete
  • Persona System Prompt
    Instructions that tell the AI when and how to use the memory tool.

How It Works

  • Memories are stored as key/value pairs in the PluginStore, namespaced per user.
  • The plugin injects memory functions into the ToolRunner via a module prepend.
  • Users can manage their memories at:
    /u/{username}/preferences/interface
  • The AI loads all memories into context (not selective retrieval).

GitHub Repository

https://github.com/BrianCraword/discourse-ai-persistent-memory

Seeking Feedback

I’d appreciate feedback on:

  • The approach of using prepend to inject into ToolRunner
  • Whether loading all memories vs. selective retrieval makes sense
  • Any security considerations I may have missed
  • General code quality improvements

Disclaimer

I’m not a programmer — this was built with AI assistance. I’m not able to provide support, but anyone is welcome to use, fork, or improve upon it. Use at your own risk.

PROMPT:

## Memory System

You have a persistent memory system via the user_memory tool. Use it to remember important facts about each user.

### When to SAVE memories:

* User mentions preferences (communication style, topics of interest, format preferences)
* User shares personal details (profession, location, hobbies)
* User mentions ongoing projects or goals
* User explicitly asks you to remember something

### When to RECALL memories:

* At the start of a new conversation, call user_memory with action "list" to see what you know
* When discussing topics that might relate to previous conversations

### Memory key conventions:

* preference_style, preference_topics, preference_format
* personal_profession, personal_location, personal_interests
* project_YYYY_MM (e.g., project_2026_01)
* goal_[topic] (e.g., goal_learning_python)

### Example usage:

* To save: `{ action: "save", key: "preference_style", value: "concise responses" }`
* To recall: `{ action: "recall", key: "personal_profession" }`
* To list all: `{ action: "list" }`
* To forget: `{ action: "forget", key: "old_key" }`

Always greet returning users by checking their memories first.

---

The tool definition itself doesn't need changes since it's already generic—just update the description parameter example if you'd like:

**Parameter description (key):** The memory key (e.g., preference_style, current_project)

Want me to adjust the tone or add/remove any specific use cases?



TOOL:

Name:        User Memory
Tool Name:   user_memory

Description:
A memory system that allows the AI to save, recall, list, and forget facts about users.
Memories persist across conversations.

Summary:
Store and recall persistent facts about the user

Parameters:
- action (string)  [REQUIRED]
  The action to perform: save, recall, list, or forget

- key (string)     [optional]
  The memory key (e.g., preference_style, current_project)

- value (string)   [optional]
  The value to store (only needed for save action)

1 Like