Improve long product-data generation runs

This commit is contained in:
wuyang6
2026-05-11 20:26:06 +08:00
parent 4c29ce21f1
commit c4427bbd07
14 changed files with 57 additions and 6 deletions
@@ -566,8 +566,16 @@ function summarizeRunEvents(runStatus: ClawActiveRunStatus) {
lines.push("后端已开始执行本轮任务。");
}
if (event.type === "tool_start") {
const stageNote =
typeof event.assistant_content === "string"
? event.assistant_content.trim()
: "";
lines.push(
event.tool_name ? `调用工具 ${event.tool_name}` : "正在调用工具",
stageNote.startsWith("进度:") || stageNote.startsWith("进度:")
? stageNote
: event.tool_name
? `调用工具 ${event.tool_name}`
: "正在调用工具",
);
}
if (event.type === "tool_result") {
@@ -636,7 +644,6 @@ function getReplayMessages(
const visibleMessages = isActiveRunStatus(runStatus)
? messages.filter((message) => !isRunStatusMessage(message))
: [...messages];
if (isActiveRunStatus(runStatus)) return visibleMessages;
return trimIncompleteReplayTail(visibleMessages);
}
@@ -1601,6 +1601,17 @@ function formatActivityDuration(ms: number) {
function compactActivityLabel(label: string, maxLength = 15) {
const normalized = label.replace(/\s+/g, " ").trim();
const progress = normalized.match(
/^进度[:]\s*批\s*(\d+)\s*\/\s*(\d+)(?:[,]\s*已生成\s*(\d+)\s*\/\s*(\d+))?/,
);
if (progress) {
const batch = `${progress[1]}/${progress[2]}`;
const count =
progress[3] && progress[4] ? `${progress[3]}/${progress[4]}` : "";
const compactProgress = `${batch}${count}`;
if (compactProgress.length <= maxLength) return compactProgress;
return batch;
}
if (normalized.length <= maxLength) return normalized;
return `${normalized.slice(0, Math.max(1, maxLength - 1))}`;
}