fix(FEEDBACK-0001): complete iteration 0 - harden context search
This commit is contained in:
@@ -11,8 +11,8 @@ import type { Snippet } from '$lib/types';
|
||||
* Select snippets from a ranked list up to a maximum token budget.
|
||||
*
|
||||
* Snippets are evaluated in order. A snippet is included when its token count
|
||||
* does not push the running total past `maxTokens`. The loop halts at the
|
||||
* first snippet that would exceed the budget.
|
||||
* does not push the running total past `maxTokens`. Oversized snippets are
|
||||
* skipped so lower-ranked results can still be considered.
|
||||
*
|
||||
* @param snippets - Ranked list of snippets (best first).
|
||||
* @param maxTokens - Inclusive upper bound on total token count.
|
||||
@@ -24,7 +24,7 @@ export function selectSnippetsWithinBudget(snippets: Snippet[], maxTokens: numbe
|
||||
let usedTokens = 0;
|
||||
|
||||
for (const snippet of snippets) {
|
||||
if (usedTokens + (snippet.tokenCount ?? 0) > maxTokens) break;
|
||||
if (usedTokens + (snippet.tokenCount ?? 0) > maxTokens) continue;
|
||||
selected.push(snippet);
|
||||
usedTokens += snippet.tokenCount ?? 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user