Skip to content

fix(memory): expose vectorScore and textScore in hybrid search results#68830

Closed
tianhaocui wants to merge 1 commit intoopenclaw:mainfrom
tianhaocui:fix-hybrid-search-expose-scores
Closed

fix(memory): expose vectorScore and textScore in hybrid search results#68830
tianhaocui wants to merge 1 commit intoopenclaw:mainfrom
tianhaocui:fix-hybrid-search-expose-scores

Conversation

@tianhaocui
Copy link
Copy Markdown
Contributor

Fixes #68166

Summary

mergeHybridResults() computes per-result vectorScore (cosine similarity) and textScore (BM25) internally but drops them when building the final output array. This prevents consumers from inspecting individual signal contributions for debugging search quality or building relevance UIs.

Changes

  1. extensions/memory-core/src/memory/hybrid.ts — Added vectorScore and textScore to the return type and the output .map() call
  2. src/memory-host-sdk/host/types.ts — Added optional vectorScore and textScore fields to MemorySearchResult
  3. packages/memory-host-sdk/src/host/types.ts — Same type update (mirrored package)

Net: 8 lines added across 3 files. Fields are optional so existing consumers are unaffected.

Test Plan

  • Run existing hybrid search tests: pnpm test extensions/memory-core/src/memory/hybrid.test.ts
  • Verify results now include vectorScore and textScore fields
  • Verify existing consumers compile without changes (fields are optional)

mergeHybridResults() computes per-result vectorScore and textScore but
drops them when building the final output array. Consumers that need
to inspect individual signal contributions (e.g. for debugging search
quality or building relevance UIs) cannot access these values.

Carry vectorScore and textScore through to the output and add them as
optional fields on MemorySearchResult so existing consumers are
unaffected.

Fixes openclaw#68166
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 19, 2026

Greptile Summary

This PR exposes vectorScore (cosine similarity) and textScore (BM25) from mergeHybridResults(), which already computed these values internally but discarded them in the final output. The fields are added as optional to both SDK MemorySearchResult type declarations and as required in the internal function return type. Both downstream pipeline stages — applyTemporalDecayToHybridResults (spread-preserves all fields) and applyMMRToHybridResults (returns original item references) — correctly propagate the new fields without modification.

Confidence Score: 5/5

Safe to merge — the change is additive only, with no behavioral changes to existing consumers.

All three files are straightforward type/field additions. The new fields were already being computed and stored; this just stops discarding them. Both pipeline stages (temporal decay and MMR) preserve extra fields correctly. The optional typing in the public SDK is backward-compatible.

No files require special attention.

Reviews (1): Last reviewed commit: "fix(memory): expose vectorScore and text..." | Re-trigger Greptile

@prtags
Copy link
Copy Markdown

prtags Bot commented Apr 23, 2026

Related work from PRtags group trusted-ibex-o48x

Title: Open PR duplicate: [Feature]: expose vectorScore and textScore in hybrid search results

Number Title
#68286 feat(memory-core): expose vectorScore and textScore in hybrid search results
#68830* fix(memory): expose vectorScore and textScore in hybrid search results

* This PR

@BunsDev
Copy link
Copy Markdown
Member

BunsDev commented Apr 25, 2026

Closing as a duplicate of #68286, which has now landed on main as 66e66f1.

#68286 includes the same component-score exposure plus regression assertions for the hybrid merge paths and a maintainer note clarifying raw component-score semantics under temporal decay/MMR.

@BunsDev BunsDev added the close:duplicate Closed as duplicate label Apr 25, 2026
@BunsDev BunsDev closed this Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

close:duplicate Closed as duplicate extensions: memory-core Extension: memory-core size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: expose vectorScore and textScore in hybrid search results

2 participants