fix: limit reroll re-extract to single latest assistant batch

This commit is contained in:
Youzini-afk
2026-03-29 19:13:46 +08:00
parent ab37e2111c
commit fc2e9abc72
3 changed files with 10 additions and 5 deletions

View File

@@ -223,7 +223,7 @@ export async function runExtractionController(runtime) {
} }
} }
export async function onManualExtractController(runtime) { export async function onManualExtractController(runtime, options = {}) {
if (runtime.getIsExtracting()) { if (runtime.getIsExtracting()) {
runtime.toastr.info("记忆提取正在进行中,请稍候"); runtime.toastr.info("记忆提取正在进行中,请稍候");
return; return;
@@ -271,6 +271,7 @@ export async function onManualExtractController(runtime) {
"手动提取中", "手动提取中",
`待处理 assistant 楼层 ${pendingAssistantTurns.length}`, `待处理 assistant 楼层 ${pendingAssistantTurns.length}`,
"running", "running",
{ syncRuntime: true, toastKind: "info", toastTitle: "ST-BME 手动提取" }, { syncRuntime: true, toastKind: "info", toastTitle: "ST-BME 手动提取" },
); );
try { try {
@@ -307,6 +308,10 @@ export async function onManualExtractController(runtime) {
if (Array.isArray(batchResult.effects?.warnings)) { if (Array.isArray(batchResult.effects?.warnings)) {
warnings.push(...batchResult.effects.warnings); warnings.push(...batchResult.effects.warnings);
} }
if (options?.drainAll === false) {
break;
}
} }
if (totals.batches === 0) { if (totals.batches === 0) {
@@ -521,7 +526,7 @@ export async function onRerollController(runtime, { fromFloor } = {}) {
timeOut: 2500, timeOut: 2500,
}); });
await runtime.onManualExtract(); await runtime.onManualExtract({ drainAll: false });
runtime.refreshPanelLiveState(); runtime.refreshPanelLiveState();
return { return {
...rollbackResult, ...rollbackResult,

View File

@@ -5058,7 +5058,7 @@ async function onFetchEmbeddingModels(mode = null) {
); );
} }
async function onManualExtract() { async function onManualExtract(options = {}) {
return await onManualExtractController({ return await onManualExtractController({
beginStageAbortController, beginStageAbortController,
clampInt, clampInt,
@@ -5086,7 +5086,7 @@ async function onManualExtract() {
}, },
setLastExtractionStatus, setLastExtractionStatus,
toastr, toastr,
}); }, options);
} }
async function onReroll({ fromFloor } = {}) { async function onReroll({ fromFloor } = {}) {

View File

@@ -28,7 +28,7 @@ const vectorSnippet = extractSnippet(
"async function ensureVectorReadyIfNeeded(", "async function ensureVectorReadyIfNeeded(",
); );
const manualExtractSnippet = extractSnippet( const manualExtractSnippet = extractSnippet(
"async function onManualExtract() {", "async function onManualExtract(options = {}) {",
"async function onReroll(", "async function onReroll(",
); );
const rebuildSnippet = extractSnippet( const rebuildSnippet = extractSnippet(