feat(bot): episodic memory context in thinking partner#45
Merged
Conversation
Surface relevant past decisions alongside vault notes and graph context when thinking about a topic. Queries episode store by entity keywords from the topic (words >= 3 chars, top 5), deduplicates across searches, and injects a "Past Decisions" section with decision, outcome, status, and up to 3 lessons per episode. Add episode_store parameter to think() and _build_vault_context(). Add _add_episodic_context() helper with lazy EpisodeStore import. Add episode_store field to HandlerContext. Wire through think handler.
9 tests covering: entity match surfaces episodes, no matches produces no section, deduplication across overlapping entity searches, None episode store graceful skip, multiple episodes all shown, pending status display, lesson truncation at 3, think() passes episode store through, and short words (< 3 chars) skipped in entity search.
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
Connect episodic memory to the thinking partner so past decisions surface alongside vault notes and graph context when thinking about a topic. Previously, the episodic store existed in isolation — episodes could be created and queried via bot commands, but the thinking partner never accessed them. Now, when a user thinks about "kubernetes scaling", relevant past decisions about kubernetes or scaling are automatically injected as context.
Inspired by memora-lab/memory-service-public's retrieval agent which pulls observations, people, and context into a unified prompt.
How It Works
Episodic Context Assembly
EpisodeStore.search_by_entity(word, limit=3)Short words (< 3 chars like "ai", "ml") are skipped to avoid noisy broad matches.
Changes
Modified Files
src/vaultmind/bot/thinking.py— Addedepisode_store: object | None = Noneparameter tothink()and_build_vault_context(). New_add_episodic_context()helper queries episodes by topic keywords, deduplicates, and formats the "Past Decisions" section. Uses lazyEpisodeStoreimport with isinstance check to avoid circular depssrc/vaultmind/bot/handlers/context.py— Addedepisode_store: object | None = field(default=None)toHandlerContextdataclasssrc/vaultmind/bot/handlers/think.py— Passesctx.episode_storetoctx.thinking.think()New Files
tests/test_episodic_thinking.py(321 lines) — 9 integration tests using realEpisodeStorewithtmp_pathBackward Compatibility
episode_storedefaults toNonein all signatures — existing callers unaffectedHandlerContext.episode_storedefaults toNone— existing handler construction unchangedepisode_storeisNone, no episodic section is generated (graceful skip)Test plan
test_episodic_thinking.py:ruff check— cleanmypy --ignore-missing-imports— clean