fix(web-probe): normalize agentrun error codes
This commit is contained in:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user