fix: improve LTM preference injection — skip relevance scoring, dedicated budget, meaningful confidence#358
Merged
Merged
Conversation
…ated budget, meaningful confidence Preferences were silently dropped because cross-project entries had no safety net in forSession() and relevance scoring (FTS5/vector) penalized generic directives like 'never push to main' that have zero keyword overlap with session context. Changes: - Add preference-only fast path in forSession() that skips relevance scoring entirely, sorts by confidence DESC then recency, and has no count cap - Give preferences a dedicated 2% budget independent of the 5% context-bound LTM budget so they no longer compete with gotchas/patterns - Add confidence parameter to ltm.create() and CuratorOp create type so the curator can set meaningful confidence (1.0=directive, 0.9=strong, 0.8=moderate) - Update curator prompt with explicit confidence semantics - Add rerankPreferences() to re-score legacy entries by directive-detection patterns and 'lore data rerank' CLI command - Auto-rerank after 'lore data recover' so imported entries get proper confidence
…d confidence in dedup, deduplicate budget function
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
forSession(): skips FTS5/vector relevance scoring for preferences (which are unconditional user directives, not contextual knowledge). Sorts byconfidence DESC, updated_at DESCwith no count cap — fixes cross-project preferences being silently dropped.ltm.create()andCuratorOpcreate ops now acceptconfidence. Curator prompt updated with explicit semantics (1.0=unconditional directive, 0.9=strong preference, 0.8=moderate, 0.6=mild).lore data rerankCLI command to re-score legacy preference entries by directive-detection patterns. Also auto-runs afterlore data recover.Problem
Most user preferences were not injected into sessions because:
forSession()and were dropped when they scored 0 on relevance (e.g., "never push to main" has zero FTS5 overlap with a React session)NO_CONTEXT_FALLBACK_CAP=10capped first-turn preferencesconfidencewas always hardcoded to 1.0, making it useless for rankingFiles Changed
packages/core/src/ltm.tsconfidenceparam oncreate(),rerankPreferences()packages/core/src/curator.tsconfidenceonCuratorOpcreate type, wired throughapplyOpspackages/core/src/prompt.tspackages/core/src/config.tspreferenceLtmbudget field (default 0.02)packages/core/src/gradient.tsgetPreferenceLtmBudget()functionpackages/core/src/index.tspackages/gateway/src/pipeline.tspackages/gateway/src/cli/data.tslore data rerankcommand, auto-rerank after recoverpackages/core/test/ltm.test.tsTesting
lore data rerankto fix existing preference entries