




















@@ -20,7 +20,7 @@ import {
2020const OPENAI_TIMEOUT_MS = 120_000;
2121const ANTHROPIC_TIMEOUT_MS = 120_000;
2222const LIVE_CACHE_LANE_RETRIES = 1;
23-const LIVE_CACHE_RESPONSE_RETRIES = 1;
23+const LIVE_CACHE_RESPONSE_RETRIES = 2;
2424const OPENAI_PREFIX = buildStableCachePrefix("openai");
2525const OPENAI_MCP_PREFIX = buildStableCachePrefix("openai-mcp-style");
2626const ANTHROPIC_PREFIX = buildStableCachePrefix("anthropic");
@@ -60,6 +60,15 @@ type LiveCacheRegressionResult = {
6060warnings: string[];
6161};
626263+class CacheProbeTextMismatchError extends Error {
64+constructor(
65+readonly suffix: string,
66+readonly text: string,
67+) {
68+super(`expected response to contain CACHE-OK ${suffix}, got ${JSON.stringify(text)}`);
69+}
70+}
71+6372const NOOP_TOOL: Tool = {
6473name: "noop",
6574description: "Return ok.",
@@ -242,17 +251,16 @@ async function completeCacheProbe(params: {
242251const text = extractAssistantText(response);
243252if (shouldRetryCacheProbeText({ attempt, suffix: params.suffix, text })) {
244253logLiveCache(
245-`${params.providerTag} cache lane ${params.suffix} response mismatch; retrying once: ${JSON.stringify(text)}`,
254+`${params.providerTag} cache lane ${params.suffix} response mismatch; retrying: ${JSON.stringify(text)}`,
246255);
247256continue;
248257}
249258const responseTextLower = normalizeLowercaseStringOrEmpty(text);
250259const suffixLower = normalizeLowercaseStringOrEmpty(params.suffix);
251260const markerLower = `cache-ok ${suffixLower}`;
252-assert(
253-responseTextLower.includes(markerLower),
254-`expected response to contain CACHE-OK ${params.suffix}, got ${JSON.stringify(text)}`,
255-);
261+if (!responseTextLower.includes(markerLower)) {
262+throw new CacheProbeTextMismatchError(params.suffix, text);
263+}
256264const usage = normalizeCacheUsage(response.usage);
257265return {
258266suffix: params.suffix,
@@ -499,12 +507,22 @@ async function runRepeatedLaneWithBaselineRetry(params: {
499507let attempts = 0;
500508for (let attempt = 1; attempt <= 1 + LIVE_CACHE_LANE_RETRIES; attempt += 1) {
501509attempts = attempt;
502-result = await runRepeatedLane({
503- ...params,
504-sessionId: `live-cache-regression-${params.runToken}-${params.providerTag}-${params.lane}${
505- attempt > 1 ? `-retry-${attempt}` : ""
506- }`,
507-});
510+try {
511+result = await runRepeatedLane({
512+ ...params,
513+sessionId: `live-cache-regression-${params.runToken}-${params.providerTag}-${params.lane}${
514+ attempt > 1 ? `-retry-${attempt}` : ""
515+ }`,
516+});
517+} catch (error) {
518+if (error instanceof CacheProbeTextMismatchError && attempt <= LIVE_CACHE_LANE_RETRIES) {
519+logLiveCache(
520+`${params.providerTag} ${params.lane} response mismatch; retrying lane once: ${error.message}`,
521+);
522+continue;
523+}
524+throw error;
525+}
508526findings = evaluateAgainstBaseline({
509527lane: params.lane,
510528provider: params.providerTag,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。