Fix Tavern regex reuse inspection and matching

This commit is contained in:
Youzini-afk
2026-04-05 02:00:37 +08:00
parent 5cc33fabda
commit e9758feed3
5 changed files with 914 additions and 355 deletions

View File

@@ -46,6 +46,13 @@ const INPUT_REGEX_STAGE_BY_FIELD = {
contradictionSummary: "input.candidateText",
};
const INPUT_REGEX_ROLE_BY_FIELD = {
userMessage: "user",
recentMessages: "mixed",
chatMessages: "mixed",
dialogueText: "mixed",
};
function cloneRuntimeDebugValue(value, fallback = null) {
if (value == null) {
return fallback;
@@ -601,6 +608,7 @@ function sanitizePromptContextInputs(
}
const value = sanitizedContext[fieldName];
const regexStage = INPUT_REGEX_STAGE_BY_FIELD[fieldName] || "";
const regexRole = INPUT_REGEX_ROLE_BY_FIELD[fieldName] || "system";
const sanitized = sanitizeStructuredPromptValue(
settings,
taskType,
@@ -610,7 +618,7 @@ function sanitizePromptContextInputs(
path: fieldName,
mode: "aggressive",
regexStage,
role: "system",
role: regexRole,
debugState,
regexCollector,
applyMvu,