Skip to content

fix(memory): filtrar resultados irrelevantes da busca semântica#10

Merged
Joao208 merged 1 commit into
mainfrom
fix/memory-search-relevance-filter
Mar 9, 2026
Merged

fix(memory): filtrar resultados irrelevantes da busca semântica#10
Joao208 merged 1 commit into
mainfrom
fix/memory-search-relevance-filter

Conversation

@Joao208

@Joao208 Joao208 commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Descricao

A busca semântica do team-memory retornava todos os top N resultados independente da relevância. Resultados com score negativo (distância > 1) são semanticamente distantes e poluíam os resultados. Adicionado threshold mínimo de -0.2 para filtrar ruído.

Etiquetas (Labels)

  • Nova Funcionalidade
  • Correcao de Bug
  • Estrutura
  • Testes
  • Outros

Historia Relacionada

N/A

Motivacao e Contexto

Ao buscar por termos específicos (ex: "arvore-eink cleartext"), a busca retornava todas as memórias do banco, incluindo resultados completamente irrelevantes com scores de -0.88, -0.99 etc. Isso polui o contexto do agente e desperdiça tokens.

Como Isso Foi Testado?

  • Testes Unitarios
  • Testes de Integracao
  • Testes e2e (playwright)
  • Testes de Aceitacao (QA)
  • Testes de Performance
  • Outros (quais?)
  • Nenhum (por que?)

Analise de Risco e Impacto

  • Baixo
  • Alto

Capturas de Tela ou Auxilios Visuais (se apropriado)

N/A

Summary by CodeRabbit

  • Bug Fixes
    • Improved semantic search result filtering to exclude low-relevance results, ensuring only higher-quality search outcomes are displayed.

The semantic search was returning all top N results regardless of relevance
score. Results with negative scores (distance > 1) are semantically distant
and should not be returned. Added a minimum relevance threshold of -0.2 to
filter out noise.
@coderabbitai

coderabbitai Bot commented Mar 9, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a9857192-dc38-422a-bd1d-33fc1d123a9e

📥 Commits

Reviewing files that changed from the base of the PR and between a100e89 and 0ac9a27.

📒 Files selected for processing (1)
  • packages/memory/src/store.ts

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Walkthrough

A minimum relevance threshold (MIN_RELEVANCE_SCORE = -0.2) was added to the semanticSearch function to filter out low-scoring results. Previously, all mapped search results were returned without filtering, regardless of relevance score.

Changes

Cohort / File(s) Summary
Semantic Search Filtering
packages/memory/src/store.ts
Added MIN_RELEVANCE_SCORE constant and post-map filtering logic to exclude semantic search results falling below the -0.2 threshold.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰✨ A threshold set with gentle care,
No more results unfit to share!
Below -0.2, they fade away,
Better searches light the way! 🔍

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/memory-search-relevance-filter

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Joao208 Joao208 merged commit c5de3e9 into main Mar 9, 2026
3 of 4 checks passed
@Joao208 Joao208 deleted the fix/memory-search-relevance-filter branch March 9, 2026 17:24
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.

1 participant