mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-30 17:26:53 +00:00
fix: add rate limit patterns for 'too many tokens' and 'tokens per day' (#39377)
Merged via squash.
Prepared head SHA: 132a457286
Co-authored-by: gambletan <266203672+gambletan@users.noreply.github.com>
Co-authored-by: altaywtf <9790196+altaywtf@users.noreply.github.com>
Reviewed-by: @altaywtf
This commit is contained in:
@@ -103,6 +103,32 @@ describe("memory embedding batches", () => {
|
||||
expect(calls).toBe(3);
|
||||
}, 10000);
|
||||
|
||||
it("retries embeddings on too-many-tokens-per-day rate limits", async () => {
|
||||
const memoryDir = fx.getMemoryDir();
|
||||
const managerSmall = fx.getManagerSmall();
|
||||
const line = "e".repeat(120);
|
||||
const content = Array.from({ length: 4 }, () => line).join("\n");
|
||||
await fs.writeFile(path.join(memoryDir, "2026-01-08.md"), content);
|
||||
|
||||
let calls = 0;
|
||||
embedBatch.mockImplementation(async (texts: string[]) => {
|
||||
calls += 1;
|
||||
if (calls === 1) {
|
||||
throw new Error("AWS Bedrock embeddings failed: Too many tokens per day");
|
||||
}
|
||||
return texts.map(() => [0, 1, 0]);
|
||||
});
|
||||
|
||||
const restoreFastTimeouts = useFastShortTimeouts();
|
||||
try {
|
||||
await managerSmall.sync({ reason: "test" });
|
||||
} finally {
|
||||
restoreFastTimeouts();
|
||||
}
|
||||
|
||||
expect(calls).toBe(2);
|
||||
}, 10000);
|
||||
|
||||
it("skips empty chunks so embeddings input stays valid", async () => {
|
||||
const memoryDir = fx.getMemoryDir();
|
||||
const managerSmall = fx.getManagerSmall();
|
||||
|
||||
Reference in New Issue
Block a user