From d744073d67f0df6adc47d24116a122daf1ae7678 Mon Sep 17 00:00:00 2001 From: Eva Date: Sat, 11 Apr 2026 05:20:30 +0700 Subject: [PATCH] fix(errors): narrow proxy transport detection --- ...embedded-helpers.formatassistanterrortext.test.ts | 12 ++++++++++++ ...pi-embedded-helpers.isbillingerrormessage.test.ts | 8 ++++++++ src/agents/pi-embedded-helpers/errors.ts | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/agents/pi-embedded-helpers.formatassistanterrortext.test.ts b/src/agents/pi-embedded-helpers.formatassistanterrortext.test.ts index e08adcebffb..478c242f676 100644 --- a/src/agents/pi-embedded-helpers.formatassistanterrortext.test.ts +++ b/src/agents/pi-embedded-helpers.formatassistanterrortext.test.ts @@ -265,6 +265,18 @@ describe("formatAssistantErrorText", () => { ); }); + it("keeps non-transport config errors that mention proxy settings actionable", () => { + const msg = makeAssistantError( + 'Model-provider request.proxy/request.tls is not yet supported for api "ollama"', + ); + expect(formatAssistantErrorText(msg)).toContain( + 'Model-provider request.proxy/request.tls is not yet supported for api "ollama"', + ); + expect(formatAssistantErrorText(msg)).not.toBe( + "LLM request failed: proxy or tunnel configuration blocked the provider request.", + ); + }); + it("sanitizes invalid streaming event order errors", () => { const msg = makeAssistantError( 'Unexpected event order, got message_start before receiving "message_stop"', diff --git a/src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts b/src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts index 73e76320049..d61a0f508ca 100644 --- a/src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts +++ b/src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts @@ -1166,4 +1166,12 @@ describe("classifyProviderRuntimeFailureKind", () => { "replay_invalid", ); }); + + it("does not classify generic config errors that mention proxy settings as proxy failures", () => { + expect( + classifyProviderRuntimeFailureKind( + 'Model-provider request.proxy/request.tls is not yet supported for api "ollama"', + ), + ).not.toBe("proxy"); + }); }); diff --git a/src/agents/pi-embedded-helpers/errors.ts b/src/agents/pi-embedded-helpers/errors.ts index 3041d01ed48..aad1c72f0ae 100644 --- a/src/agents/pi-embedded-helpers/errors.ts +++ b/src/agents/pi-embedded-helpers/errors.ts @@ -470,7 +470,7 @@ const AUTH_SCOPE_NAME_RE = /\b(?:api\.responses\.write|model\.request)\b/i; const HTML_BODY_RE = /^\s*(?:/i; const PROXY_ERROR_RE = - /\bproxy\b|\bproxyconnect\b|\bhttps?_proxy\b|\b407\b|\bproxy authentication required\b|\btunnel connection failed\b|\bconnect tunnel\b|\bsocks proxy\b/i; + /\bproxyconnect\b|\bhttps?_proxy\b|\b407\b|\bproxy authentication required\b|\btunnel connection failed\b|\bconnect tunnel\b|\bsocks proxy\b|\bproxy error\b/i; const DNS_ERROR_RE = /\benotfound\b|\beai_again\b|\bgetaddrinfo\b|\bno such host\b|\bdns\b/i; const INTERRUPTED_NETWORK_ERROR_RE = /\beconnrefused\b|\beconnreset\b|\beconnaborted\b|\benetreset\b|\behostunreach\b|\behostdown\b|\benetunreach\b|\bepipe\b|\bsocket hang up\b|\bconnection refused\b|\bconnection reset\b|\bconnection aborted\b|\bnetwork is unreachable\b|\bhost is unreachable\b|\bfetch failed\b|\bconnection error\b|\bnetwork request failed\b/i;