fix(recall): deterministic persisted reapply on reroll (Phase 1 inject-decoupling)

Reroll (swipe/regenerate/continue = no-new-user) now deterministically
reapplies the parent user floor's stored bme_recall block in
GENERATE_BEFORE_COMBINE_PROMPTS, bypassing the transaction gate and
runRecall entirely. AFTER_COMMANDS defers no-new-user work to
before-combine. Staleness guard recomputes when the user edited the
floor; settings gate honors plugin/recall disable. Fresh normal sends
are unaffected. Compute machinery retained as fallback.
This commit is contained in:
youzini
2026-06-01 05:52:45 +00:00
parent f1764669d9
commit f986bcc293
6 changed files with 348 additions and 1 deletions

View File

@@ -577,6 +577,15 @@ export async function onGenerationAfterCommandsController(
return;
}
const generationContext = runtime.getGenerationContext?.() || null;
const kind = generationContext?.kind || "";
if (kind === "no-new-user") {
return {
skipped: true,
reason: "no-new-user-deferred-to-before-combine",
};
}
const frozenInputSnapshot =
generationType === "normal"
? runtime.consumeHostGenerationInputSnapshot?.({ preserve: true }) ||
@@ -585,7 +594,6 @@ export async function onGenerationAfterCommandsController(
const context = runtime.getContext();
const chat = context?.chat;
const generationContext = runtime.getGenerationContext?.() || null;
const recallOptions = runtime.buildGenerationAfterCommandsRecallInput(
generationContext?.type || type,
@@ -780,6 +788,16 @@ export async function onBeforeCombinePromptsController(
}
if (effectiveGenerationKind === "no-new-user") {
const reapplied = runtime.reapplyPersistedRecallBlock?.({
generationType: effectiveGenerationType,
generationContext,
promptData,
hookName: "GENERATE_BEFORE_COMBINE_PROMPTS",
});
if (reapplied?.applied) {
return reapplied;
}
const recallOptions =
runtime.buildGenerationAfterCommandsRecallInput(
effectiveGenerationType,