Skip to content

OB1-inspired features: recency-boosted search + companion prompt packs#57

Merged
imonroe merged 3 commits into
mainfrom
claude/ob1-memserve-feature-review-Xpxhp
Jun 4, 2026
Merged

OB1-inspired features: recency-boosted search + companion prompt packs#57
imonroe merged 3 commits into
mainfrom
claude/ob1-memserve-feature-review-Xpxhp

Conversation

@imonroe
Copy link
Copy Markdown
Owner

@imonroe imonroe commented Jun 4, 2026

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/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).

  • Defaults to 0 → no-op: existing search behavior is completely 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); when recency_weight > 0 each result carries a rerank_score for transparency.
  • New app/ranking.py::rerank_by_recency(); wired into app/rest.py and app/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 end
  • research-synthesis.md — findings with confidence levels + open questions
  • meeting-synthesis.md — decisions, action items, risks
  • Cross-linked from the User Guide's memory-prompting section.

Architecture notes

  • No invariants touched: single Memory per process, MCP reads remain unscoped by agent_id, no new storage. Recency re-ranking is pure post-processing on the already-returned result set.

Tests

  • New tests/test_ranking.py (10 cases: weight=0 no-op, recency promotion, similarity-dominant at low weight, missing/unparseable/metadata/updated_at timestamps, non-dict passthrough, single-item).
  • Added REST cases (default no-rerank, rerank, out-of-range rejected) and MCP cases (param exposed, invocation).
  • Full suite: 88 passed, ruff check clean.

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

claude added 2 commits June 4, 2026 00:28
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
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 when recency_weight > 0.
  • Expose recency_weight (and REST-only recency_half_life_days) via REST /memories/search and the MCP search_memories tool.
  • 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.

Comment thread app/ranking.py Outdated
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
@imonroe imonroe merged commit d0afc03 into main Jun 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ship companion prompts / skill docs (auto-capture, research synthesis, meeting synthesis) Recency-boosted search ranking option

3 participants