feat(context): episodic memory — recall how a similar task was solved before#23
Merged
Conversation
… before Companion to user-preference modeling (#22). Instead of rediscovering a recurring job, QodeX records a lean episode after each objectively-successful task and, at the start of a new one, recalls the most SIMILAR past task on this project and injects a one-line reminder of what worked. Off by default (learning.episodicMemory.enabled). Clean + lightweight, same discipline as #22: - src/context/episodic-memory.ts (pure rank + thin I/O): records to ~/.qodex/episodes/<project>.jsonl; rankEpisodes scores a query against past episodes by lexical TF-cosine (reuses the tested similarity primitives — no embedding dependency), excludes near-identical re-runs (score ≥ 0.98), returns top-K above a similarity threshold; buildEpisodeBlock renders a concise block. - SMART, not always-on: an unrelated task injects nothing (below threshold), and only a one-line summary is injected, never full transcripts. - Loop hooks: record at the objective-success point (alongside capture/dataset); inject the recalled block into the system prompt at run start. - The lexical ranker is a pure function, so an embedding-backed variant can be swapped in later without touching call sites. Also: completed the README Self-learning section with the episodic-memory step, its config, and a worked end-to-end example. Live-verified: recorded two episodes, a pagination-shaped query recalled the pagination episode (with files), an unrelated k8s query recalled nothing. Tests: 6 (similar-retrieval, unrelated→empty, self-match excluded, topK/sort, empty guards). typecheck + full suite (1189) + build green.
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.
The remaining genuinely-new gap from the review (#2). Companion to user-preference modeling (#22) — instead of rediscovering a recurring job, QodeX recalls how it solved a similar task before.
How it works
~/.qodex/episodes/<project>.jsonl.learning.episodicMemory.enabled).Clean + lightweight (same discipline as #22)
src/context/episodic-memory.ts— purerankEpisodes/buildEpisodeBlock(reuses the already-tested similarity primitives, no embedding dependency) + thin JSONL I/O.Live-verified
Recorded two episodes → a pagination-shaped query recalled the pagination episode (with files); an unrelated k8s query recalled nothing.
Also
Completed the README Self-learning section: the episodic-memory step + config, and a worked end-to-end example (addresses review item #3).
Tests
6 (similar-retrieval, unrelated→empty, self-match excluded, topK/sort, empty guards). ✅ typecheck · ✅ full suite (1189) · ✅ build.