Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alphaxiv/agents",
"version": "0.7.1",
"version": "0.7.2",
"license": "MIT",
"fmt": {
"lineWidth": 120
Expand Down
5 changes: 3 additions & 2 deletions src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ function isLikelyServerError(text: string): boolean {
const lower = text.toLowerCase();
return (
lower.includes("had an error processing your request") ||
lower.includes("missing finish_reason")
lower.includes("missing finish_reason") ||
lower.includes("error while downloading file")
);
}

Expand All @@ -117,7 +118,7 @@ function isLikelyAttachmentRejected(text: string): boolean {
return (
lower.includes("invalid pdf structure") ||
lower.includes("does not represent a valid image") ||
lower.includes("error while downloading file")
lower.includes("failed to decode image data")
);
}

Expand Down
1 change: 1 addition & 0 deletions src/retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ function getStrategyBehavior(kind: ErrorKind, strategy: ResolvedRetryStrategy):
switch (kind) {
case "aborted":
case "invalid_attachment":
case "attachment_rejected":
case "content_filtered":
return "no-retry";
case "timeout":
Expand Down
13 changes: 11 additions & 2 deletions tests/simple/errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,19 @@ const testCases: ClassifyErrorTestCase[] = [
expected: { kind: "attachment_rejected" },
},
{
name: "classifies a provider failing to download the file as attachment_rejected",
error: { message: "Error while downloading file. Upstream status code: 404.", status: 400 },
name: "classifies Vertex failing to decode the image bytes as attachment_rejected",
error: {
message:
'{"error":{"message":"{\\n \\"error\\": {\\n \\"code\\": 400,\\n \\"message\\": \\"Failed to decode image data. Please make sure the image is valid.\\",\\n \\"status\\": \\"INVALID_ARGUMENT\\"\\n }\\n}\\n","code":400,"status":"Bad Request"}}',
status: 400,
},
expected: { kind: "attachment_rejected" },
},
{
name: "classifies a provider failing to download the file as server",
error: { message: "Error while downloading file. Upstream status code: 404.", status: 400 },
expected: { kind: "server" },
},
{
name: "classifies InvalidAttachmentError as invalid_attachment",
error: new InvalidAttachmentError(
Expand Down
2 changes: 1 addition & 1 deletion tests/simple/retry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const defaultBehaviorMatrix: Array<{ kind: ErrorKind; expected: RetryBehavior }>
{ kind: "context_overflow", expected: "switch-model" },
{ kind: "image_too_large", expected: "switch-model" },
{ kind: "invalid_attachment", expected: "no-retry" },
{ kind: "attachment_rejected", expected: "switch-model" },
{ kind: "attachment_rejected", expected: "no-retry" },
{ kind: "content_filtered", expected: "no-retry" },
];

Expand Down
Loading