fix(gsd): extract real error from message content when errorMessage is useless
When errorMessage is uninformative (e.g. "success", "ok"), fall back to the assistant message text content for display while keeping rawErrorMsg for classification to avoid prose false-positives. Fixes #3588 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
eaeced4774
commit
0b6dfd0bbf
1 changed files with 8 additions and 5 deletions
|
|
@ -100,16 +100,19 @@ export async function handleAgentEnd(
|
|||
// errorMessage looks uninformative.
|
||||
const rawErrorMsg = ("errorMessage" in lastMsg && lastMsg.errorMessage) ? String(lastMsg.errorMessage) : "";
|
||||
const isUseless = !rawErrorMsg || /^(success|ok|true|error|unknown)$/i.test(rawErrorMsg.trim());
|
||||
let errorMsg = rawErrorMsg;
|
||||
// #3588: When errorMessage is uninformative, extract the real error from
|
||||
// the assistant message text content for display purposes only.
|
||||
// Classification still uses rawErrorMsg to avoid false positives from prose.
|
||||
let displayMsg = rawErrorMsg;
|
||||
if (isUseless && "content" in lastMsg && Array.isArray(lastMsg.content)) {
|
||||
const textBlock = lastMsg.content.find((b: any) => b.type === "text" && b.text);
|
||||
if (textBlock) errorMsg = (textBlock as any).text.slice(0, 300);
|
||||
if (textBlock) displayMsg = (textBlock as any).text.slice(0, 300);
|
||||
}
|
||||
const errorDetail = errorMsg ? `: ${errorMsg}` : "";
|
||||
const errorDetail = displayMsg ? `: ${displayMsg}` : "";
|
||||
const explicitRetryAfterMs = ("retryAfterMs" in lastMsg && typeof lastMsg.retryAfterMs === "number") ? lastMsg.retryAfterMs : undefined;
|
||||
|
||||
// ── 1. Classify ──────────────────────────────────────────────────────
|
||||
const cls = classifyError(errorMsg, explicitRetryAfterMs);
|
||||
// ── 1. Classify using rawErrorMsg to avoid prose false-positives ────
|
||||
const cls = classifyError(rawErrorMsg, explicitRetryAfterMs);
|
||||
|
||||
// Cap rate-limit backoff for CLI-style providers (openai-codex, google-gemini-cli)
|
||||
// which use per-user quotas with shorter windows (#2922).
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue