mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-23 00:38:13 +00:00
fix(agents): check billing errors before context overflow heuristics (#40409)
Merged via squash.
Prepared head SHA: c88f89c462
Co-authored-by: ademczuk <5212682+ademczuk@users.noreply.github.com>
Co-authored-by: altaywtf <9790196+altaywtf@users.noreply.github.com>
Reviewed-by: @altaywtf
This commit is contained in:
@@ -439,6 +439,18 @@ describe("isLikelyContextOverflowError", () => {
|
||||
expect(isLikelyContextOverflowError(sample)).toBe(false);
|
||||
}
|
||||
});
|
||||
|
||||
it("excludes billing errors even when text matches context overflow patterns", () => {
|
||||
const samples = [
|
||||
"402 Payment Required: request token limit exceeded for this billing plan",
|
||||
"insufficient credits: request size exceeds your current plan limits",
|
||||
"Your credit balance is too low. Maximum request token limit exceeded.",
|
||||
];
|
||||
for (const sample of samples) {
|
||||
expect(isBillingErrorMessage(sample)).toBe(true);
|
||||
expect(isLikelyContextOverflowError(sample)).toBe(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("isTransientHttpError", () => {
|
||||
|
||||
@@ -138,6 +138,13 @@ export function isLikelyContextOverflowError(errorMessage?: string): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Billing/quota errors can contain patterns like "request size exceeds" or
|
||||
// "maximum token limit exceeded" that match the context overflow heuristic.
|
||||
// Billing is a more specific error class — exclude it early.
|
||||
if (isBillingErrorMessage(errorMessage)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (CONTEXT_WINDOW_TOO_SMALL_RE.test(errorMessage)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user