feat(FN-1462): add context window exceeds limit pattern to context-limit-detector

- Add new regex pattern /context\s+window\s+exceeds/i to match provider JSON error
  envelope variant: "context window exceeds limit (2013)"
- Add 4 new test cases for the variant pattern
- Pattern is conservative: requires both "context window" and "exceeds" present
This commit is contained in:
gsxdsm
2026-04-10 03:02:38 -07:00
parent dd77c79718
commit f246fe4896
2 changed files with 23 additions and 0 deletions

View File

@@ -39,6 +39,9 @@ const CONTEXT_OVERFLOW_PATTERNS: RegExp[] = [
/too many tokens/i,
// Anthropic variant: "messages with that many tokens would exceed"
/tokens? would exceed/i,
// Provider JSON error envelope variant: "context window exceeds limit (2013)"
// Matches when "context window" and "exceeds" appear together (order-flexible)
/context\s+window\s+exceeds/i,
];
/**