fix(sf): getRelevantMemoriesRanked pool size never less than limit
Pool was Math.min(50, limit * 5). For default limit=10 this gives 50 (intended 5× oversample for rerank). But for limit=100 it gives 50 — caller asking for 100 results would silently get at most 50. Now: max(limit, limit * 5), capped at 200 to bound rerank latency on huge requests. Default behavior unchanged for limit ≤ 10; large requests now work correctly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e2e708fc11
commit
0426e61cea
1 changed files with 6 additions and 1 deletions
|
|
@ -156,7 +156,12 @@ export async function getRelevantMemoriesRanked(
|
|||
limit = 10,
|
||||
): Promise<Memory[]> {
|
||||
if (!isDbAvailable()) return [];
|
||||
const pool = getActiveMemoriesRanked(Math.min(50, limit * 5));
|
||||
// Pool sizing: 5× oversample for the embedding rerank to be meaningful,
|
||||
// but never less than `limit` itself — otherwise asking for limit=100
|
||||
// would silently cap at pool=50 and return only 50 results. Hard ceiling
|
||||
// at 200 to bound rerank latency on huge requests.
|
||||
const poolSize = Math.min(200, Math.max(limit, limit * 5));
|
||||
const pool = getActiveMemoriesRanked(poolSize);
|
||||
if (pool.length === 0 || !query.trim()) {
|
||||
return pool.slice(0, limit);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue