mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-23 02:45:38 -06:00
fix(release): repair validation correlations (#108489)
This commit is contained in:
committed by
GitHub
parent
bc55e1ea3e
commit
343a93ded3
@@ -2226,9 +2226,10 @@ function sessionMessagesAfterNextUserTurn(
|
||||
expectedUserText?: string,
|
||||
): unknown[] {
|
||||
const nextUserOffset = messages.slice(baselineMessageCount).findIndex((message) => {
|
||||
const actualUserText = extractTranscriptMessageText(message);
|
||||
return (
|
||||
(message as { role?: unknown } | null | undefined)?.role === "user" &&
|
||||
(expectedUserText === undefined || extractTranscriptMessageText(message) === expectedUserText)
|
||||
(expectedUserText === undefined || matchesLiveProbeUserText(actualUserText, expectedUserText))
|
||||
);
|
||||
});
|
||||
if (nextUserOffset < 0) {
|
||||
@@ -2237,6 +2238,20 @@ function sessionMessagesAfterNextUserTurn(
|
||||
return messages.slice(baselineMessageCount + nextUserOffset + 1);
|
||||
}
|
||||
|
||||
function matchesLiveProbeUserText(actual: string, expected: string): boolean {
|
||||
if (actual === expected) {
|
||||
return true;
|
||||
}
|
||||
const markerIndex = expected.indexOf(`${ANTHROPIC_MAGIC_STRING_TRIGGER_REFUSAL}_`);
|
||||
if (markerIndex < 0) {
|
||||
return false;
|
||||
}
|
||||
const nonceSuffix = expected.slice(markerIndex + ANTHROPIC_MAGIC_STRING_TRIGGER_REFUSAL.length);
|
||||
// The embedded Anthropic runtime scrubs the refusal trigger before persisting it.
|
||||
// Its random suffix survives and still uniquely owns this live probe turn.
|
||||
return /^_[a-f0-9]{32}$/.test(nonceSuffix) && actual.endsWith(nonceSuffix);
|
||||
}
|
||||
|
||||
function sessionAssistantEntriesForLiveProbe(
|
||||
messages: readonly unknown[],
|
||||
modelKey?: string,
|
||||
@@ -2401,6 +2416,20 @@ describe("latestAssistantTextAfterBaseline", () => {
|
||||
);
|
||||
expect(latestTerminalAssistantTextAfterBaseline(secondEntries, 0)).toBe("second-a second-b");
|
||||
});
|
||||
|
||||
it("correlates Anthropic refusal probes after the runtime scrubs their trigger", () => {
|
||||
const nonce = "0123456789abcdef0123456789abcdef";
|
||||
const expected = `Reply with ok. ${ANTHROPIC_MAGIC_STRING_TRIGGER_REFUSAL}_${nonce}`;
|
||||
const scrubbed = `Reply with ok. ANTHROPIC MAGIC STRING TRIGGER REFUSAL (redacted)_${nonce}`;
|
||||
|
||||
expect(matchesLiveProbeUserText(scrubbed, expected)).toBe(true);
|
||||
expect(
|
||||
matchesLiveProbeUserText(
|
||||
"Reply with ok. ANTHROPIC MAGIC STRING TRIGGER REFUSAL (redacted)_ffffffffffffffffffffffffffffffff",
|
||||
expected,
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
async function waitForSessionAssistantText(params: {
|
||||
|
||||
Reference in New Issue
Block a user