2.2 KiB
2.2 KiB
Phase 3 PR #1 Checklist: Adaptive Memory Injection and Compaction Weighting
Created: 2026-02-12 Owner: Flynn core Status: ready to implement
Goal
Improve memory usefulness and compaction quality by injecting relevant memory context adaptively and preserving high-value turns during compaction.
Scope
In scope:
- adaptive memory relevance scoring
- configurable memory injection strategy
- compaction weighting for important turns (tool outcomes, corrections, preferences)
- tests and perf guardrails
Out of scope:
- new vector backend work
- UI controls for weighting
Files
New:
src/memory/adaptive.tssrc/memory/adaptive.test.tssrc/context/weighting.tssrc/context/weighting.test.ts
Modified:
src/backends/native/orchestrator.tssrc/context/compaction.tssrc/memory/store.tssrc/config/schema.ts
Implementation Steps
- Add adaptive memory scorer:
- keyword overlap with recent turns
- recency weighting
- token budget clipping
- Add config flags:
memory.injection_strategy(all|recent|adaptive)memory.max_injection_tokenscompaction.importance_threshold
- Integrate adaptive injector in orchestrator memory injection path.
- Add compaction message weighting and selection algorithm.
- Ensure fallback to existing behavior on errors/timeouts.
- Add tests for relevance selection and weighted compaction ordering.
Validation Commands
pnpm typecheck
pnpm test:run src/memory/adaptive.test.ts
pnpm test:run src/context/weighting.test.ts
pnpm test:run src/context/compaction.test.ts
pnpm test:run src/backends/native/orchestrator.test.ts
pnpm test:run
pnpm lint
pnpm build
Acceptance Criteria
- Adaptive mode injects fewer but more relevant memory snippets.
- Compaction preserves high-importance turns over low-value chatter.
- Token budgets are respected consistently.
- Existing behavior preserved when adaptive features disabled.
- No measurable latency regression beyond agreed budget.
Risks
- Relevance scoring false positives/negatives.
- Mitigation: conservative scoring + extensive fixtures.
- Added latency in hot path.
- Mitigation: bounded scoring time and fallback mode.
Commit Message
feat(memory): add adaptive injection and weighted compaction