open-agents-ai 0.185.27 → 0.185.28
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 +39 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26413,7 +26413,36 @@ If you're stuck, try a completely different approach. Do NOT repeat what failed
|
|
|
26413
26413
|
this.emit({ type: "error", content: `Model not available. Use /model to select a different model.`, timestamp: (/* @__PURE__ */ new Date()).toISOString() });
|
|
26414
26414
|
break;
|
|
26415
26415
|
}
|
|
26416
|
-
|
|
26416
|
+
let imageRecovered = false;
|
|
26417
|
+
if (/invalid image|image.*invalid|image_url.*unsupported|does not support.*image|image.*not supported/i.test(errMsg)) {
|
|
26418
|
+
this.emit({
|
|
26419
|
+
type: "status",
|
|
26420
|
+
content: `Backend rejected image \u2014 stripping images and retrying`,
|
|
26421
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
26422
|
+
});
|
|
26423
|
+
for (const msg2 of messages) {
|
|
26424
|
+
if (Array.isArray(msg2.content)) {
|
|
26425
|
+
const textParts = msg2.content.filter((p) => p.type !== "image_url");
|
|
26426
|
+
if (textParts.length > 0) {
|
|
26427
|
+
msg2.content = textParts.length === 1 && textParts[0].text ? textParts[0].text : textParts;
|
|
26428
|
+
} else {
|
|
26429
|
+
msg2.content = "[Image was here but backend doesn't support images]";
|
|
26430
|
+
}
|
|
26431
|
+
}
|
|
26432
|
+
}
|
|
26433
|
+
chatRequest.messages = messages;
|
|
26434
|
+
try {
|
|
26435
|
+
const imgRetry = this.options.streamEnabled && this.hasStreamingSupport() ? await this.streamingRequest(chatRequest, turn) : await this.backend.chatCompletion(chatRequest);
|
|
26436
|
+
response = imgRetry;
|
|
26437
|
+
imageRecovered = true;
|
|
26438
|
+
} catch (imgRetryErr) {
|
|
26439
|
+
const msg2 = imgRetryErr instanceof Error ? imgRetryErr.message : String(imgRetryErr);
|
|
26440
|
+
this.emit({ type: "error", content: `Retry without images also failed: ${msg2}`, timestamp: (/* @__PURE__ */ new Date()).toISOString() });
|
|
26441
|
+
break;
|
|
26442
|
+
}
|
|
26443
|
+
}
|
|
26444
|
+
if (imageRecovered) {
|
|
26445
|
+
} else if (/does not support tools|HTTP 400.*tools/i.test(errMsg)) {
|
|
26417
26446
|
this.emit({
|
|
26418
26447
|
type: "status",
|
|
26419
26448
|
content: `Model lacks native tool support \u2014 switching to prompt-injected tool mode`,
|
|
@@ -26464,14 +26493,16 @@ If you're stuck, try a completely different approach. Do NOT repeat what failed
|
|
|
26464
26493
|
break;
|
|
26465
26494
|
}
|
|
26466
26495
|
}
|
|
26467
|
-
|
|
26468
|
-
|
|
26469
|
-
|
|
26470
|
-
|
|
26471
|
-
|
|
26472
|
-
|
|
26496
|
+
if (!imageRecovered) {
|
|
26497
|
+
this.emit({
|
|
26498
|
+
type: "error",
|
|
26499
|
+
content: `Backend unavailable \u2014 stopping task. Fix the issue and retry.`,
|
|
26500
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
26501
|
+
});
|
|
26502
|
+
break;
|
|
26503
|
+
}
|
|
26473
26504
|
}
|
|
26474
|
-
response = recovered;
|
|
26505
|
+
response = recovered ?? response;
|
|
26475
26506
|
}
|
|
26476
26507
|
totalTokens += response.usage?.totalTokens ?? 0;
|
|
26477
26508
|
promptTokens += response.usage?.promptTokens ?? 0;
|
package/package.json
CHANGED