fix(openclaw): prevent memory wipe on every session#323
Merged
nicoloboschi merged 1 commit intovectorize-io:mainfrom Feb 9, 2026
Merged
fix(openclaw): prevent memory wipe on every session#323nicoloboschi merged 1 commit intovectorize-io:mainfrom
nicoloboschi merged 1 commit intovectorize-io:mainfrom
Conversation
Use unique document_id per conversation (sessionKey + timestamp) instead of static sessionKey. The backend CASCADE-deletes old memories when the same document_id is reused, causing all prior facts to be lost. Also: - Universal envelope stripping for all channels (was Telegram-only) - Prefer rawMessage over prompt for cleaner recall queries - Increase recall max_tokens from 512 to 2048 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
nicoloboschi
approved these changes
Feb 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
document_idper conversation (sessionKey + timestamp) instead of static sessionKey. The backend CASCADE-deletes old memories when the samedocument_idis reused, causing all prior facts to be lost on every new conversation.[Telegram ...]extraction with generic channel support (Slack, Discord, WhatsApp, Signal, etc.) for cleaner recall queries.event.rawMessageoverevent.promptwhen available to avoid envelope-formatted prompts.max_tokensfrom 512 to 2048 for richer memory injection.Root Cause
The
agent_endhook retained transcripts withdocument_idset to the staticsessionKey(alwaysagent:main:main). The backend'shandle_document_tracking()doesDELETE FROM documents WHERE id = $1 AND bank_id = $2with CASCADE before inserting — wiping ALL previous memory_units and entity_links tied to that document. Every conversation replaced the previous one.Test plan
cd hindsight-integrations/openclaw && npm run buildagent:main:main-1739083800000)🤖 Generated with Claude Code