From 0c8f1f2902bcac6e8ac0a39eaf493f79d6332a95 Mon Sep 17 00:00:00 2001 From: Codex Date: Sat, 20 Jun 2026 18:05:06 +0000 Subject: [PATCH] fix(web-probe): normalize agentrun error codes --- .../hwlab-node-web-observe-runner-source.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/src/hwlab-node-web-observe-runner-source.ts b/scripts/src/hwlab-node-web-observe-runner-source.ts index b7591911..ec7c3949 100644 --- a/scripts/src/hwlab-node-web-observe-runner-source.ts +++ b/scripts/src/hwlab-node-web-observe-runner-source.ts @@ -1060,12 +1060,16 @@ function sampleExecutionErrorCandidates(sample) { add("message", sample?.messages); add("trace-row", sample?.traceRows); add("turn", sample?.turns); - return candidates; + const specific = candidates.filter((candidate) => { + const parsed = parseExecutionErrorText(candidate.text); + return parsed && parsed.code !== "error"; + }); + return specific.length > 0 ? specific : candidates; } function parseExecutionErrorText(text) { const value = String(text || ""); - const agentRunCodeMatch = value.match(/\bagentrun:error:([a-z0-9_.:-]+)/iu); + const agentRunCodeMatch = value.match(/\bagentrun:error:([A-Za-z0-9_.:-]+)/u); const agentRunText = /\bAgentRun\s+error\b|\bagentrun:error:/iu.test(value); const providerUnavailable = /\bprovider[-_\s]*unavailable\b/iu.test(value); if (!agentRunCodeMatch && !agentRunText && !providerUnavailable) return null; @@ -1073,17 +1077,23 @@ function parseExecutionErrorText(text) { const traceMatch = value.match(/\btrc_[A-Za-z0-9_-]+\b/u); const totalMatch = value.match(/\btotal\s*=\s*([0-9]{1,2}:[0-9]{2}(?::[0-9]{2})?)\b/iu) || value.match(/总耗时\s*[::]?\s*([0-9]{1,2}:[0-9]{2}(?::[0-9]{2})?)/iu); - const rawCode = agentRunCodeMatch ? "agentrun:error:" + agentRunCodeMatch[1] : providerUnavailable ? "provider-unavailable" : "agentrun:error"; + const agentRunCode = cleanExecutionCode(agentRunCodeMatch?.[1] || ""); + const rawCode = agentRunCode ? "agentrun:error:" + agentRunCode : providerUnavailable ? "provider-unavailable" : "agentrun:error"; return { backend: agentRunText || agentRunCodeMatch ? "agentrun" : "unknown", status: normalizeExecutionStatus(statusMatch?.[1] || "error"), - code: agentRunCodeMatch?.[1] || (providerUnavailable ? "provider-unavailable" : "error"), + code: agentRunCode || (providerUnavailable ? "provider-unavailable" : "error"), rawCode, totalSeconds: totalMatch ? parseClockDurationSeconds(totalMatch[1]) : null, traceId: traceMatch?.[0] || null }; } +function cleanExecutionCode(code) { + const value = String(code || "").replace(/(?:AgentRun|Error|Failed).*$/u, "").replace(/[^A-Za-z0-9_.:-].*$/u, ""); + return value || null; +} + function normalizeExecutionStatus(status) { const value = String(status || "").toLowerCase(); if (value === "failed") return "fail";