mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-23 08:31:49 +00:00
* fix(ai): compress Catty requests only after 413 * fix(ai): retry 413 after tool progress safely * fix(ai): mark thrown 413 retries after tool progress * fix(ai): preserve tool results in 413 retry
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import {
|
|
createCattyRequestTooLargeRetryError,
|
|
hadToolProgressBeforeRequestTooLarge,
|
|
} from "./cattyRequestTooLargeRetry.ts";
|
|
|
|
test("createCattyRequestTooLargeRetryError marks 413 retry errors after tool progress", () => {
|
|
const source = Object.assign(new Error("HTTP 413 Request Entity Too Large"), {
|
|
status: 413,
|
|
responseBody: "<html>too large</html>",
|
|
});
|
|
|
|
const retryError = createCattyRequestTooLargeRetryError(source, true);
|
|
|
|
assert.equal(retryError.statusCode, 413);
|
|
assert.equal(retryError.status, 413);
|
|
assert.equal(retryError.responseBody, "<html>too large</html>");
|
|
assert.equal(retryError.cause, source);
|
|
assert.equal(hadToolProgressBeforeRequestTooLarge(retryError), true);
|
|
});
|
|
|
|
test("hadToolProgressBeforeRequestTooLarge is false when no tool progress was recorded", () => {
|
|
const retryError = createCattyRequestTooLargeRetryError("HTTP 413", false);
|
|
|
|
assert.equal(hadToolProgressBeforeRequestTooLarge(retryError), false);
|
|
assert.equal(hadToolProgressBeforeRequestTooLarge(new Error("HTTP 413")), false);
|
|
});
|