OB1-inspired features: recency-boosted search + companion prompt packs#57
Merged
Merged
Conversation
Search (REST POST /api/v1/memories/search and the MCP search_memories tool) can now blend mem0's semantic similarity with a recency decay via an optional recency_weight (0.0-1.0). It defaults to 0, which is a no-op: existing search behavior is unchanged. Similarity scores are min-max normalized across the result set so the two signals are comparable; items without a usable timestamp are never boosted. REST also exposes recency_half_life_days (default 30). Implements the recency-boosted-match idea adapted from the OB1 project. - app/ranking.py: rerank_by_recency() helper - app/rest.py, app/mcp_server.py: wire the option into both search paths - tests/test_ranking.py + additions to test_rest.py/test_mcp.py - docs: USER_GUIDE search section, DEVELOPER_GUIDE module map https://claude.ai/code/session_017835DVrvURaYnbQiPQwzue
Reusable, copy-paste prompt packs that drive the six MCP tools for recurring tasks, adapted from the OB1 project's skill packs for this server's single-user model and tool names. Documentation only; no server changes. - docs/prompts/README.md: index + how to use - docs/prompts/auto-capture.md: save a structured session summary at session end - docs/prompts/research-synthesis.md: findings with confidence + open questions - docs/prompts/meeting-synthesis.md: decisions, action items, risks - docs/USER_GUIDE.md: cross-link the packs from the memory-prompting section https://claude.ai/code/session_017835DVrvURaYnbQiPQwzue
There was a problem hiding this comment.
Pull request overview
Adds opt-in, post-processing recency re-ranking to memory search results (REST + MCP) and introduces documentation-only “companion prompt packs” to help users drive the existing MCP tools more effectively.
Changes:
- Implement
rerank_by_recency()to blend normalized similarity with a recency decay whenrecency_weight > 0. - Expose
recency_weight(and REST-onlyrecency_half_life_days) via REST/memories/searchand the MCPsearch_memoriestool. - Add
docs/prompts/prompt-pack docs and cross-link them from the User Guide.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| app/rest.py | Adds recency_weight + recency_half_life_days to REST search request and applies re-ranking post-search. |
| app/ranking.py | New re-ranking implementation (timestamp parsing + blended scoring + in-place result sorting). |
| app/mcp_server.py | Exposes recency_weight on MCP search_memories and applies re-ranking post-search. |
| tests/test_rest.py | Adds REST tests for default no-op behavior, rerank behavior, and range validation. |
| tests/test_ranking.py | Adds focused unit tests for reranking behavior and edge cases. |
| tests/test_mcp.py | Verifies MCP tool schema exposes recency_weight and that search invocation still scopes correctly. |
| docs/USER_GUIDE.md | Documents optional recency boost and links to new prompt packs. |
| docs/DEVELOPER_GUIDE.md | Documents the new app/ranking.py module in the architecture overview. |
| docs/prompts/README.md | Introduces prompt-pack concept and usage guidance. |
| docs/prompts/auto-capture.md | Adds an “auto-capture” session-summary prompt pack. |
| docs/prompts/research-synthesis.md | Adds a research-synthesis prompt pack. |
| docs/prompts/meeting-synthesis.md | Adds a meeting-synthesis prompt pack. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The previous comment framed the 'Z' normalization around pre-3.11 behavior, which read as if it were required on supported versions. Python 3.11+ (and the project's 3.12 target) already accept 'Z' in fromisoformat; the rewrite is a harmless explicit-UTC normalization. Reword to say so. https://claude.ai/code/session_017835DVrvURaYnbQiPQwzue
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
First batch of improvements adapted from a review of the OB1 / Open Brain project (see the feature backlog issues #48–#56). These are the highest-value / lowest-effort, fully-verifiable items; each is self-contained and ships with tests and docs.
1. Opt-in recency-boosted search ranking (closes #53)
Search — both
POST /api/v1/memories/searchand the MCPsearch_memoriestool — can now blend mem0's semantic similarity with a recency decay via an optionalrecency_weight(0.0–1.0).recency_half_life_days(default 30); whenrecency_weight > 0each result carries arerank_scorefor transparency.app/ranking.py::rerank_by_recency(); wired intoapp/rest.pyandapp/mcp_server.py.2. Companion prompt packs (closes #56)
Documentation-only reusable prompt packs under
docs/prompts/that drive the existing six MCP tools for recurring tasks, adapted from OB1's "skill packs":auto-capture.md— save a structured session summary at session endresearch-synthesis.md— findings with confidence levels + open questionsmeeting-synthesis.md— decisions, action items, risksArchitecture notes
Memoryper process, MCP reads remain unscoped byagent_id, no new storage. Recency re-ranking is pure post-processing on the already-returned result set.Tests
tests/test_ranking.py(10 cases: weight=0 no-op, recency promotion, similarity-dominant at low weight, missing/unparseable/metadata/updated_attimestamps, non-dict passthrough, single-item).ruff checkclean.Not included here (and why)
From the backlog, these are higher-effort or need validation against a live Qdrant (mem0 abstracts the payload layer), so they're deliberately deferred to follow-up PRs rather than shipped unverified:
https://claude.ai/code/session_017835DVrvURaYnbQiPQwzue
Generated by Claude Code