From cb4a06ce5cf2f2fa1f88c799a46bb2bf6b089f2f Mon Sep 17 00:00:00 2001 From: Akhil <133588800+Akhil373@users.noreply.github.com> Date: Wed, 22 Apr 2026 03:30:12 +0530 Subject: [PATCH] fix: surface readable error messages in web-scraping agent and ai-provider (#5476) * fix: surface readable error messages in web-scraping agent and ai-provider * simplify --------- Co-authored-by: Timothy Carambat --- server/utils/agents/aibitat/plugins/web-scraping.js | 7 ++++--- server/utils/agents/aibitat/providers/ai-provider.js | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/server/utils/agents/aibitat/plugins/web-scraping.js b/server/utils/agents/aibitat/plugins/web-scraping.js index bc5f66cc..ad35ce86 100644 --- a/server/utils/agents/aibitat/plugins/web-scraping.js +++ b/server/utils/agents/aibitat/plugins/web-scraping.js @@ -49,13 +49,14 @@ const webScraping = { if (url) return await this.scrape(url); return "There is nothing we can do. This function call returns no information."; } catch (error) { + const errorMessage = error?.message ?? JSON.stringify(error); this.super.handlerProps.log( - `Web Scraping Error: ${error.message}` + `Web Scraping Error: ${errorMessage}` ); this.super.introspect( - `${this.caller}: Web Scraping Error: ${error.message}` + `${this.caller}: Web Scraping Error: ${errorMessage}` ); - return `There was an error while calling the function. No data or response was found. Let the user know this was the error: ${error.message}`; + return `There was an error while calling the function. No data or response was found. Let the user know this was the error: ${errorMessage}`; } }, diff --git a/server/utils/agents/aibitat/providers/ai-provider.js b/server/utils/agents/aibitat/providers/ai-provider.js index ea8dc2b0..2a51bb16 100644 --- a/server/utils/agents/aibitat/providers/ai-provider.js +++ b/server/utils/agents/aibitat/providers/ai-provider.js @@ -406,7 +406,9 @@ class Provider { ...config, }); default: - throw new Error(`Unsupported provider ${provider} for this task.`); + throw new Error( + `Unsupported provider ${JSON.stringify(provider)} for this task.` + ); } }