diff --git a/server/utils/agents/aibitat/plugins/web-browsing.js b/server/utils/agents/aibitat/plugins/web-browsing.js index e4fde566642..ecba79e27fa 100644 --- a/server/utils/agents/aibitat/plugins/web-browsing.js +++ b/server/utils/agents/aibitat/plugins/web-browsing.js @@ -1770,6 +1770,7 @@ const webBrowsing = { method: "POST", headers, body: JSON.stringify({ query: String(query), max_results: 10 }), + signal: AbortSignal.timeout(20_000), } ) .then(async (res) => { @@ -1789,6 +1790,10 @@ const webBrowsing = { throw new Error( data?.message || `API error code ${data?.code}` ); + if (!Array.isArray(data?.data?.results)) + throw new Error( + "Malformed response: code 0 but no data.results" + ); return { response: data, error: null }; }) .catch((e) => {