feat(toolcall): harden confusable candidate spans

This commit is contained in:
Your Name
2026-05-10 09:27:30 +07:00
parent 6a8edf96c3
commit 196e3c46f6
20 changed files with 2257 additions and 363 deletions

View File

@@ -7,6 +7,10 @@ const {
SKIP_EXACT_PATHS,
} = require('../shared/deepseek-constants');
const LEAKED_BOS_MARKER_PATTERN = /<[|]\s*begin[_▁]of[_▁]sentence\s*[|]>/gi;
const LEAKED_THOUGHT_MARKER_PATTERN = /<[|]\s*(?:begin[_▁])?[_▁]*of[_▁]thought\s*[|]>/gi;
const LEAKED_META_MARKER_PATTERN = /<[|]\s*(?:assistant|tool|end[_▁]of[_▁]sentence|end[_▁]of[_▁]thinking|end[_▁]of[_▁]thought|end[_▁]of[_▁]toolresults|end[_▁]of[_▁]instructions)\s*[|]>/gi;
function stripThinkTags(text) {
@@ -621,7 +625,11 @@ function stripReferenceMarkersText(text) {
if (!text) {
return text;
}
return text.replace(/\[(?:citation|reference):\s*\d+\]/gi, '');
return text
.replace(/\[(?:citation|reference):\s*\d+\]/gi, '')
.replace(LEAKED_BOS_MARKER_PATTERN, '')
.replace(LEAKED_THOUGHT_MARKER_PATTERN, '')
.replace(LEAKED_META_MARKER_PATTERN, '');
}
function asString(v) {