fix: isolate visual tool failures from agent runs

This commit is contained in:
john
2026-07-27 19:20:23 +08:00
parent 7002007128
commit 17c59fde71
10 changed files with 444 additions and 16 deletions
+9
View File
@@ -36,6 +36,12 @@ function messageContentItems(event) {
export function classifySessionProviderErrorMessage(message) {
const normalized = String(message ?? '').trim();
if (!normalized) return 'SESSION_REPLY_ERROR';
if (
/unknown variant [`']?image_url[`']?.*expected [`']?text/i.test(normalized)
|| /failed to deserialize.*image_url/i.test(normalized)
) {
return 'SESSION_VISUAL_CONTEXT_UNSUPPORTED';
}
if (/tool_calls|tool_call_id|insufficient tool messages/i.test(normalized)) {
return 'SESSION_TOOL_HISTORY_POISONED';
}
@@ -60,6 +66,9 @@ function providerReplyError(event) {
.trim();
const error = new Error(normalized || 'session reply failed');
error.code = classifySessionProviderErrorMessage(normalized);
if (error.code === 'SESSION_VISUAL_CONTEXT_UNSUPPORTED') {
error.retryable = false;
}
return error;
}