refactor(js): align tool-sieve segment start and tail window with go

This commit is contained in:
CJACK. committed 2026-03-30 15:41:26 +08:00
1 parent ab3943ebeb
commit 775bf3b578
3 files changed
+3 -7

No files matched your search

@@ -197,11 +197,7 @@ function findToolSegmentStart(state, s) {
}
const keyIdx = bestKeyIdx;
const start = s.slice(0, keyIdx).lastIndexOf('{');
if (start < 0) {
offset = keyIdx + matchedKeyword.length;
continue;
}
let candidateStart = start;
let candidateStart = start >= 0 ? start : keyIdx;
// If the keyword matched inside an XML tag (e.g. "tool_calls" in "<tool_calls>"),
// back up past the '<' to capture the full tag.
if (candidateStart > 0 && s[candidateStart - 1] === '<') {
@@ -1,6 +1,6 @@
'use strict';
const TOOL_SIEVE_CONTEXT_TAIL_LIMIT = 4096;
const TOOL_SIEVE_CONTEXT_TAIL_LIMIT = 256;
function createToolSieveState() {
return {