-
Notifications
You must be signed in to change notification settings - Fork 385
Feature request: can avoid storing interactions in episodic memory #1101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: can avoid storing interactions in episodic memory #1101
Conversation
|
Hi @fatualux , thank you for the clear explanation and proposal The problem with the This is an inherent problem with hooks, they can read and change stuff but not really deactivate the process. In Basically I am closing this PR, hopefully we can talk again about this on Thanks again! Appreciated |
|
Thanks so much to you,
I understand the point :)
Il Dom 17 Ago 2025, 14:36 Piero Savastano ***@***.***> ha
scritto:
… Closed #1101 <#1101>.
—
Reply to this email directly, view it on GitHub
<#1101 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIPQJXELKCJCQ3QZEVZ5URD3OBZN5AVCNFSM6AAAAACDZMNI66VHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJZGE4TCMJSGIYTONQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
Hi @pieroit, Thank you for your response. While we acknowledge and accept your choice, I’d like to take a moment to reinforce @fatualux’s point in hopes that you might reconsider his proposal. The approach of checking the value of 1. Backward compatibility with existing codeBy allowing the hook to return a tuple, we can bypass the specific check in if tea_spoon is not None:
tea_cup = tea_spoonThis ensures that 2. Low Probability of breaking existing pluginsThe likelihood of an existing plugin already returning a tuple in the doc = self.mad_hatter.execute_hook(
"before_cat_stores_episodic_memory", doc, cat=self
)
# store user message in episodic memory
# TODO: vectorize and store also conversation chunks
# (not raw dialog, but summarization)
user_message_embedding = self.embedder.embed_documents([user_message_text])
_ = self.memory.vectors.episodic.add_point(
doc.page_content,
user_message_embedding[0],
doc.metadata,
)If 3. Expressing the intentThe proposed implementation explicitly indicates the intent behind returning a tuple like
Maybe this intention would be more readable if expressed this way instead of the pattern matching: def _store_user_message_in_episodic_memory(self, user_message_text: str):
doc = Document(
page_content=user_message_text,
metadata={"source": self.user_id, "when": time.time()},
)
doc = self.mad_hatter.execute_hook(
"before_cat_stores_episodic_memory", doc, cat=self
)
if isinstance(doc, tuple) and len(doc) == 2:
doc, skip_storage = doc
if doc is None and skip_storage:
return
# store user message in episodic memory
# TODO: vectorize and store also conversation chunks
# (not raw dialog, but summarization)
user_message_embedding = self.embedder.embed_documents([user_message_text])
_ = self.memory.vectors.episodic.add_point(
doc.page_content,
user_message_embedding[0],
doc.metadata,
)To sum up: I see the point of having a broken plugin hook's pipe, but this happens on the explicit intention of the plugin author, and only in the case he decide to return If you still believe it’s better to reject this proposal, we sincerely thank you for your time and consideration. Best regards |
|
Hi @lucapiccinelli thanks for chiming in. My view on the topic is:
As already stated, I am moving the vector memory in a plugin, in branch |
|
Ok @pieroit thank you for the answer |
Description
The context
As always, thanks for your work, and the time you may dedicate to my proposal.
Currently, we cannot avoid storing interactions between users and Cat to "episodic memories"
However, we can go around this limitation for our use case with CheshireCat.
Our workaround
Currently, the method
_store_user_message_in_episodic_memorydoes not provide the possibility to avoid storing episodic memories:So, by no, we are using the
before_cat_stores_episodic_memoryhook to overwrite theDocumentattributes with empty ones:This "trick" works as intended, but leads to some inconvenients.
For instance, we need to run a cron job to periodically clean up the episodic memory.
Type of change
At first, we thought returning None inside the
before_cat_stores_episodic_memoryhook and adding a check in_store_user_message_in_episodic_memorywould work.However, this approach does not work, because of this logic (
/cat/mad_hatter/mad_hatter.py):Our proposal is to use "pattern matching" in
/cat/looking_glass/stray_cat.py, line 656:if
Documentis a tuple withNoneandTrue, we skip storing it in episodic memory:And here is
before_cat_stores_episodic_memoryhook in our plugin:Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to not work as expected)
This change requires a documentation update
Checklist: