mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 11:37:38 +00:00
fix(agents): exclude rate limit errors from context overflow classification (#13747)
Co-authored-by: 0xRaini <rain@0xRaini.dev>
This commit is contained in:
@@ -1,14 +1,5 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import { isLikelyContextOverflowError } from "./pi-embedded-helpers.js";
|
import { isLikelyContextOverflowError } from "./pi-embedded-helpers.js";
|
||||||
import { DEFAULT_AGENTS_FILENAME } from "./workspace.js";
|
|
||||||
|
|
||||||
const _makeFile = (overrides: Partial<WorkspaceBootstrapFile>): WorkspaceBootstrapFile => ({
|
|
||||||
name: DEFAULT_AGENTS_FILENAME,
|
|
||||||
path: "/tmp/AGENTS.md",
|
|
||||||
content: "",
|
|
||||||
missing: false,
|
|
||||||
...overrides,
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("isLikelyContextOverflowError", () => {
|
describe("isLikelyContextOverflowError", () => {
|
||||||
it("matches context overflow hints", () => {
|
it("matches context overflow hints", () => {
|
||||||
@@ -31,4 +22,17 @@ describe("isLikelyContextOverflowError", () => {
|
|||||||
expect(isLikelyContextOverflowError(sample)).toBe(false);
|
expect(isLikelyContextOverflowError(sample)).toBe(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("excludes rate limit errors that match the broad hint regex", () => {
|
||||||
|
const samples = [
|
||||||
|
"request reached organization TPD rate limit, current: 1506556, limit: 1500000",
|
||||||
|
"rate limit exceeded",
|
||||||
|
"too many requests",
|
||||||
|
"429 Too Many Requests",
|
||||||
|
"exceeded your current quota",
|
||||||
|
];
|
||||||
|
for (const sample of samples) {
|
||||||
|
expect(isLikelyContextOverflowError(sample)).toBe(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -40,6 +40,12 @@ export function isLikelyContextOverflowError(errorMessage?: string): boolean {
|
|||||||
if (CONTEXT_WINDOW_TOO_SMALL_RE.test(errorMessage)) {
|
if (CONTEXT_WINDOW_TOO_SMALL_RE.test(errorMessage)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Rate limit errors can match the broad CONTEXT_OVERFLOW_HINT_RE pattern
|
||||||
|
// (e.g., "request reached organization TPD rate limit" matches request.*limit).
|
||||||
|
// Exclude them before checking context overflow heuristics.
|
||||||
|
if (isRateLimitErrorMessage(errorMessage)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (isContextOverflowError(errorMessage)) {
|
if (isContextOverflowError(errorMessage)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user