fix(recall): pass generation context to primary reroll path + trace gates

This commit is contained in:
youzini
2026-05-31 21:05:59 +00:00
parent c81a91f485
commit 52c3d59e0e
2 changed files with 67 additions and 4 deletions

View File

@@ -585,12 +585,14 @@ export async function onGenerationAfterCommandsController(
const context = runtime.getContext();
const chat = context?.chat;
const generationContext = runtime.getGenerationContext?.() || null;
const recallOptions = runtime.buildGenerationAfterCommandsRecallInput(
type,
generationContext?.type || type,
{
...params,
frozenInputSnapshot,
generationContext,
},
chat,
);
@@ -601,6 +603,26 @@ export async function onGenerationAfterCommandsController(
return;
}
if (globalThis.__stBmeDebugLoggingEnabled === true) {
const tail = Array.isArray(chat)
? chat.slice(-3).map((m, i) => ({
idx: chat.length - 3 + i,
is_user: Boolean(m?.is_user),
hasRecall: Boolean(m?.extra?.bme_recall),
mes: String(m?.mes || "").slice(0, 40),
}))
: null;
console.warn("[ST-BME][reroll-trace] AFTER_COMMANDS enter", {
type,
generationContextType: generationContext?.type || null,
generationContextKind: generationContext?.kind || null,
recallOptionsSource: recallOptions?.overrideSource || recallOptions?.source || null,
recallOptionsType: recallOptions?.generationType || null,
targetUserMessageIndex: recallOptions?.targetUserMessageIndex ?? null,
chatTail: tail,
});
}
const recallContext = runtime.createGenerationRecallContext({
hookName: "GENERATION_AFTER_COMMANDS",
generationType,