fix(web-probe): ignore non-terminal trace rows for completion checks (#750)
Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
@@ -4931,10 +4931,23 @@ function normalizeTraceTimingRow(text, source, rowIndex, meta = {}) {
|
||||
eventTimestamp: meta.eventTimestamp || null,
|
||||
eventTimeText: meta.eventTimeText || null,
|
||||
eventKind: meta.eventKind || null,
|
||||
isCompletion: /轮次完成|turn\s+completed|completed\s+turn|terminal[_: -]?status|backend[_: -]?turn[_: -]?finished/i.test([preview, meta.eventKind || ""].join(" ")),
|
||||
isCompletion: traceRowIsTerminalCompletionText(preview, meta.eventKind || ""),
|
||||
};
|
||||
}
|
||||
|
||||
function traceRowIsTerminalCompletionText(preview, eventKind = "") {
|
||||
const value = [preview, eventKind].map((item) => String(item || "")).join(" ");
|
||||
if (/\bnon[-_ ]?terminal\b/i.test(value)) return false;
|
||||
if (/轮次完成|turn\s+completed|completed\s+turn|backend[_: -]?turn[_: -]?finished/i.test(value)) return true;
|
||||
return /\bterminal(?:[_: -]?status|Status)?\s*[=: -]\s*(?:completed|failed|cancelled|canceled|timeout)\b/i.test(value);
|
||||
}
|
||||
|
||||
function traceRowIsRoundCompletionText(preview, eventKind = "") {
|
||||
const value = [preview, eventKind].map((item) => String(item || "")).join(" ");
|
||||
if (/\bnon[-_ ]?terminal\b/i.test(value)) return false;
|
||||
return /轮次完成|turn\s+completed|completed\s+turn|backend[_: -]?turn[_: -]?finished/i.test(value);
|
||||
}
|
||||
|
||||
function traceRowCandidateArrays(sample, timelineItem) {
|
||||
const candidates = [];
|
||||
const pushArray = (rows, source, meta = {}) => {
|
||||
@@ -5299,7 +5312,7 @@ function roundCompletionEventsForSample(sample, timelineItem) {
|
||||
const rows = [];
|
||||
for (const item of traceTimingRowsForSample(sample, timelineItem)) {
|
||||
const text = String(item?.preview || item?.text || item?.textPreview || "");
|
||||
if (!item?.isCompletion && !/轮次完成/iu.test(text)) continue;
|
||||
if (!traceRowIsRoundCompletionText(text, item?.eventKind || "")) continue;
|
||||
const elapsedValues = [
|
||||
Number(item?.totalSeconds),
|
||||
...parseTotalElapsedSeconds(text).filter(Number.isFinite)
|
||||
|
||||
Reference in New Issue
Block a user