fix(backend): stop reasoning replay placeholder from self-poisoning (#9573) (#9610)

Merge-train validated (tip 6ce4effef8). Vitest failures confirmed as base-red (#9679).
This commit is contained in:
stanley
2026-08-08 06:54:23 +07:00
committed by GitHub
parent 8cb51b7922
commit 552f2e1563
4 changed files with 62 additions and 18 deletions

View File

@@ -81,6 +81,8 @@ export function setReasoningCache(
reasoning: string,
ttlMs: number = DEFAULT_TTL_MS
): void {
const PLACEHOLDER = "(prior reasoning summary unavailable)";
if (!reasoning || reasoning.trim() === PLACEHOLDER) return; // ponytail: never store the internal placeholder
if (reasoning.length > MAX_ENTRY_BYTES) {
reasoning = reasoning.slice(0, MAX_ENTRY_BYTES);
}
@@ -110,6 +112,8 @@ export function getReasoningCache(
)
.get(toolCallId) as { reasoning: string; provider: string; model: string } | undefined;
const PLACEHOLDER = "(prior reasoning summary unavailable)";
if (row && row.reasoning && row.reasoning.trim() === PLACEHOLDER) return null; // ponytail: never replay the placeholder
return row ?? null;
}