@agentv/core 4.5.0 → 4.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -16514,7 +16514,9 @@ async function runEvalCase(options) {
16514
16514
  });
16515
16515
  } catch (error) {
16516
16516
  lastError = error;
16517
- if (isTimeoutLike(error) && attempt + 1 < attemptBudget) {
16517
+ if (attempt + 1 < attemptBudget) {
16518
+ const delayMs = retryBackoffMs(attempt);
16519
+ await sleep3(delayMs, signal);
16518
16520
  attempt += 1;
16519
16521
  continue;
16520
16522
  }
@@ -17210,7 +17212,7 @@ async function invokeProvider(provider, options) {
17210
17212
  }
17211
17213
  }
17212
17214
  function buildErrorResult(evalCase, targetName, timestamp, error, promptInputs, provider, failureStage, failureReasonCode, verbose) {
17213
- const message = error instanceof Error ? error.message : String(error);
17215
+ const message = extractErrorMessage(error);
17214
17216
  let agentRequest;
17215
17217
  let lmRequest;
17216
17218
  if (isAgentProvider(provider)) {
@@ -17327,20 +17329,45 @@ function aggregateEvaluatorTokenUsage(scores) {
17327
17329
  ...hasCached ? { cached } : {}
17328
17330
  };
17329
17331
  }
17330
- function isTimeoutLike(error) {
17331
- if (!error) {
17332
- return false;
17333
- }
17334
- if (typeof DOMException !== "undefined" && error instanceof DOMException && error.name === "AbortError") {
17335
- return true;
17336
- }
17332
+ function extractErrorMessage(error) {
17337
17333
  if (error instanceof Error) {
17338
- const name = error.name?.toLowerCase();
17339
- const message = error.message?.toLowerCase();
17340
- return name.includes("timeout") || message.includes("timeout");
17334
+ return error.message;
17335
+ }
17336
+ if (error !== null && typeof error === "object") {
17337
+ const obj = error;
17338
+ const parts = [];
17339
+ if (typeof obj.message === "string" && obj.message) {
17340
+ parts.push(obj.message);
17341
+ }
17342
+ if (typeof obj.code === "number") {
17343
+ parts.push(`(code ${obj.code})`);
17344
+ }
17345
+ if (parts.length > 0) {
17346
+ return parts.join(" ");
17347
+ }
17348
+ try {
17349
+ return JSON.stringify(error);
17350
+ } catch {
17351
+ }
17341
17352
  }
17342
- const value = String(error).toLowerCase();
17343
- return value.includes("timeout");
17353
+ return String(error);
17354
+ }
17355
+ function retryBackoffMs(attempt) {
17356
+ return Math.min(2 ** attempt * 1e3, 3e4);
17357
+ }
17358
+ function sleep3(ms, signal) {
17359
+ if (signal?.aborted) return Promise.resolve();
17360
+ return new Promise((resolve) => {
17361
+ const timer = setTimeout(resolve, ms);
17362
+ signal?.addEventListener(
17363
+ "abort",
17364
+ () => {
17365
+ clearTimeout(timer);
17366
+ resolve();
17367
+ },
17368
+ { once: true }
17369
+ );
17370
+ });
17344
17371
  }
17345
17372
  function mapChildResults(children) {
17346
17373
  if (!children || children.length === 0) {