← Back to PRs

#22855: Add Chinese context overflow patterns to isContextOverflowError

by Clawborn open 2026-02-21 19:12 View on GitHub →
agents size: XS trusted-contributor
## Problem Proxy providers serving Chinese-language users (or Chinese LLM gateways) return context overflow errors in Chinese, e.g.: - `上下文过长` — context too long - `上下文超出限制` — context exceeded limit - `请压缩上下文后重试` — please compress context and retry These are not matched by the existing English-only patterns in `isContextOverflowError()`, so auto-compaction never triggers. The session gets stuck with no recovery. ## Fix Add the five most common Chinese proxy patterns as explicit string checks. Chinese characters are unaffected by `toLowerCase()` so the check is made against the original message. ## Test Added a test case in `iscontextoverflowerror.e2e.test.ts` covering all five added patterns and common wrapping formats. Closes #22849 <!-- greptile_comment --> <h3>Greptile Summary</h3> Adds detection for five common Chinese context overflow error patterns from proxy providers serving Chinese-language users. These patterns (`上下文过长`, `上下文超出`, `上下文长度超`, `超出最大上下文`, `请压缩上下文`) enable auto-compaction to trigger correctly when Chinese proxies return localized error messages, preventing sessions from getting stuck. The implementation correctly checks against the original error message (not lowercased) since Chinese characters don't have case variations, and includes comprehensive test coverage for both standalone and wrapped error formats. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk - The change is narrowly scoped (adds 5 substring checks for Chinese error patterns), well-tested with comprehensive test cases covering various formats, follows existing code patterns, and addresses a legitimate internationalization gap. The implementation correctly handles Chinese text (checks original message, not lowercased version) and the added patterns are specific enough to avoid false positives. - No files require special attention <sub>Last reviewed commit: 775f294</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs