Skip to content

feat(memory): add task-relevance ranking with boost tags and min relevance filter#89

Merged
Siddhant-K-code merged 1 commit into
mainfrom
feat/task-relevance-ranking
May 9, 2026
Merged

feat(memory): add task-relevance ranking with boost tags and min relevance filter#89
Siddhant-K-code merged 1 commit into
mainfrom
feat/task-relevance-ranking

Conversation

@Siddhant-K-code

Copy link
Copy Markdown
Owner

What

Adds task-aware relevance ranking to memory recall. Callers can now boost specific tags, provide task context for source matching, and filter out low-relevance results.

Why

As memory grows, the signal-to-noise ratio degrades. Returning everything that's semantically similar isn't enough — the agent needs context ranked by what matters for the current task, not just what exists.

Changes

New RecallRequest fields

  • boost_tags — tags that receive a +0.1 relevance boost during ranking
  • task_context — free-text task description; memories whose source matches get a +0.05 boost
  • min_relevance — filter threshold (0-1); memories below this score are excluded from results

Ranking formula

relevance = (1 - recency_weight) × similarity + recency_weight × recency
          + 0.1  (if any tag matches boost_tags)
          + 0.05 (if source appears in task_context)
          + 0.05 (if text appears in task_context)
clamped to [0, 1]

Tests

6 new tests: boost tags tipping ranking, min relevance filtering, zero min (no filter), task context source boost, relevance clamping, empty boost (no effect).

Usage

# Boost auth-related memories for the current task
curl -X POST localhost:8080/v1/memory/recall -d '{
  "query": "how does login work?",
  "query_embedding": [...],
  "boost_tags": ["auth", "security"],
  "task_context": "fixing the login flow in code_review",
  "min_relevance": 0.3,
  "max_results": 5
}'

Closes #78

…vance filter

- Add BoostTags field to RecallRequest for tag-based relevance boosting
- Add TaskContext field for source-matching relevance boost
- Add MinRelevance field to filter low-scoring results
- Relevance scores clamped to [0, 1]
- 6 new tests: boost tags, min relevance, task context, clamping, no-op

Closes #78

Co-authored-by: Ona <no-reply@ona.com>
@Siddhant-K-code Siddhant-K-code added the enhancement New feature or request label May 9, 2026
@Siddhant-K-code Siddhant-K-code merged commit c55a1cc into main May 9, 2026
2 checks passed
@Siddhant-K-code Siddhant-K-code deleted the feat/task-relevance-ranking branch May 9, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rank retrieved context by task relevance at query time

1 participant