Skip to content

Add Chinese context overflow patterns to isContextOverflowError#22855

Merged
vincentkoc merged 1 commit intoopenclaw:mainfrom
Clawborn:fix-context-overflow-chinese-patterns
Feb 23, 2026
Merged

Add Chinese context overflow patterns to isContextOverflowError#22855
vincentkoc merged 1 commit intoopenclaw:mainfrom
Clawborn:fix-context-overflow-chinese-patterns

Conversation

@Clawborn
Copy link

@Clawborn Clawborn commented Feb 21, 2026

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 Summary

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.

Confidence Score: 5/5

  • 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

Last reviewed commit: 775f294

Proxy providers returning Chinese error messages (e.g. Chinese LLM
gateways) use patterns like '上下文过长' or '上下文超出' that are not
matched by the existing English-only patterns in isContextOverflowError.
This prevents auto-compaction from triggering, leaving the session stuck.

Add the most common Chinese proxy patterns:
- 上下文过长 (context too long)
- 上下文超出 (context exceeded)
- 上下文长度超 (context length exceeds)
- 超出最大上下文 (exceeds maximum context)
- 请压缩上下文 (please compress context)

Chinese characters are unaffected by toLowerCase() so check the
original message directly.

Closes openclaw#22849

Co-authored-by: Clawborn <tianrun.yang103@gmail.com>
@vincentkoc vincentkoc force-pushed the fix-context-overflow-chinese-patterns branch from 775f294 to f71641a Compare February 23, 2026 15:47
@vincentkoc
Copy link
Member

Rebased onto latest main and refactored to current test/layout conventions.

What changed in this update:

Validation run:

  • pnpm test src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts src/agents/pi-embedded-helpers.formatassistanterrortext.test.ts
  • Passed (56/56 tests).

@vincentkoc vincentkoc merged commit 544809b into openclaw:main Feb 23, 2026
25 checks passed
vincentkoc added a commit that referenced this pull request Feb 23, 2026
jaydiamond42 pushed a commit to jaydiamond42/bloomtbot that referenced this pull request Feb 23, 2026
…claw#22855)

Proxy providers returning Chinese error messages (e.g. Chinese LLM
gateways) use patterns like '上下文过长' or '上下文超出' that are not
matched by the existing English-only patterns in isContextOverflowError.
This prevents auto-compaction from triggering, leaving the session stuck.

Add the most common Chinese proxy patterns:
- 上下文过长 (context too long)
- 上下文超出 (context exceeded)
- 上下文长度超 (context length exceeds)
- 超出最大上下文 (exceeds maximum context)
- 请压缩上下文 (please compress context)

Chinese characters are unaffected by toLowerCase() so check the
original message directly.

Closes openclaw#22849
jaydiamond42 pushed a commit to jaydiamond42/bloomtbot that referenced this pull request Feb 23, 2026
carlosrivera pushed a commit to myascendai/meshiclaw that referenced this pull request Feb 23, 2026
…claw#22855)

Proxy providers returning Chinese error messages (e.g. Chinese LLM
gateways) use patterns like '上下文过长' or '上下文超出' that are not
matched by the existing English-only patterns in isContextOverflowError.
This prevents auto-compaction from triggering, leaving the session stuck.

Add the most common Chinese proxy patterns:
- 上下文过长 (context too long)
- 上下文超出 (context exceeded)
- 上下文长度超 (context length exceeds)
- 超出最大上下文 (exceeds maximum context)
- 请压缩上下文 (please compress context)

Chinese characters are unaffected by toLowerCase() so check the
original message directly.

Closes openclaw#22849
carlosrivera pushed a commit to myascendai/meshiclaw that referenced this pull request Feb 23, 2026
mreedr pushed a commit to mreedr/openclaw-custom that referenced this pull request Feb 24, 2026
…claw#22855)

Proxy providers returning Chinese error messages (e.g. Chinese LLM
gateways) use patterns like '上下文过长' or '上下文超出' that are not
matched by the existing English-only patterns in isContextOverflowError.
This prevents auto-compaction from triggering, leaving the session stuck.

Add the most common Chinese proxy patterns:
- 上下文过长 (context too long)
- 上下文超出 (context exceeded)
- 上下文长度超 (context length exceeds)
- 超出最大上下文 (exceeds maximum context)
- 请压缩上下文 (please compress context)

Chinese characters are unaffected by toLowerCase() so check the
original message directly.

Closes openclaw#22849
mreedr pushed a commit to mreedr/openclaw-custom that referenced this pull request Feb 24, 2026
plgs2005 pushed a commit to plgs2005/openclaw that referenced this pull request Feb 24, 2026
…claw#22855)

Proxy providers returning Chinese error messages (e.g. Chinese LLM
gateways) use patterns like '上下文过长' or '上下文超出' that are not
matched by the existing English-only patterns in isContextOverflowError.
This prevents auto-compaction from triggering, leaving the session stuck.

Add the most common Chinese proxy patterns:
- 上下文过长 (context too long)
- 上下文超出 (context exceeded)
- 上下文长度超 (context length exceeds)
- 超出最大上下文 (exceeds maximum context)
- 请压缩上下文 (please compress context)

Chinese characters are unaffected by toLowerCase() so check the
original message directly.

Closes openclaw#22849
plgs2005 pushed a commit to plgs2005/openclaw that referenced this pull request Feb 24, 2026
margulans pushed a commit to margulans/Neiron-AI-assistant that referenced this pull request Feb 25, 2026
…claw#22855)

Proxy providers returning Chinese error messages (e.g. Chinese LLM
gateways) use patterns like '上下文过长' or '上下文超出' that are not
matched by the existing English-only patterns in isContextOverflowError.
This prevents auto-compaction from triggering, leaving the session stuck.

Add the most common Chinese proxy patterns:
- 上下文过长 (context too long)
- 上下文超出 (context exceeded)
- 上下文长度超 (context length exceeds)
- 超出最大上下文 (exceeds maximum context)
- 请压缩上下文 (please compress context)

Chinese characters are unaffected by toLowerCase() so check the
original message directly.

Closes openclaw#22849
margulans pushed a commit to margulans/Neiron-AI-assistant that referenced this pull request Feb 25, 2026
brianleach pushed a commit to brianleach/openclaw that referenced this pull request Feb 26, 2026
…claw#22855)

Proxy providers returning Chinese error messages (e.g. Chinese LLM
gateways) use patterns like '上下文过长' or '上下文超出' that are not
matched by the existing English-only patterns in isContextOverflowError.
This prevents auto-compaction from triggering, leaving the session stuck.

Add the most common Chinese proxy patterns:
- 上下文过长 (context too long)
- 上下文超出 (context exceeded)
- 上下文长度超 (context length exceeds)
- 超出最大上下文 (exceeds maximum context)
- 请压缩上下文 (please compress context)

Chinese characters are unaffected by toLowerCase() so check the
original message directly.

Closes openclaw#22849
brianleach pushed a commit to brianleach/openclaw that referenced this pull request Feb 26, 2026
mylukin pushed a commit to mylukin/openclaw that referenced this pull request Feb 26, 2026
…claw#22855)

Proxy providers returning Chinese error messages (e.g. Chinese LLM
gateways) use patterns like '上下文过长' or '上下文超出' that are not
matched by the existing English-only patterns in isContextOverflowError.
This prevents auto-compaction from triggering, leaving the session stuck.

Add the most common Chinese proxy patterns:
- 上下文过长 (context too long)
- 上下文超出 (context exceeded)
- 上下文长度超 (context length exceeds)
- 超出最大上下文 (exceeds maximum context)
- 请压缩上下文 (please compress context)

Chinese characters are unaffected by toLowerCase() so check the
original message directly.

Closes openclaw#22849
mylukin pushed a commit to mylukin/openclaw that referenced this pull request Feb 26, 2026
r4jiv007 pushed a commit to r4jiv007/openclaw that referenced this pull request Feb 28, 2026
…claw#22855)

Proxy providers returning Chinese error messages (e.g. Chinese LLM
gateways) use patterns like '上下文过长' or '上下文超出' that are not
matched by the existing English-only patterns in isContextOverflowError.
This prevents auto-compaction from triggering, leaving the session stuck.

Add the most common Chinese proxy patterns:
- 上下文过长 (context too long)
- 上下文超出 (context exceeded)
- 上下文长度超 (context length exceeds)
- 超出最大上下文 (exceeds maximum context)
- 请压缩上下文 (please compress context)

Chinese characters are unaffected by toLowerCase() so check the
original message directly.

Closes openclaw#22849
r4jiv007 pushed a commit to r4jiv007/openclaw that referenced this pull request Feb 28, 2026
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 1, 2026
(cherry picked from commit ae66a4b)
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 3, 2026
(cherry picked from commit ae66a4b)
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
…claw#22855)

Proxy providers returning Chinese error messages (e.g. Chinese LLM
gateways) use patterns like '上下文过长' or '上下文超出' that are not
matched by the existing English-only patterns in isContextOverflowError.
This prevents auto-compaction from triggering, leaving the session stuck.

Add the most common Chinese proxy patterns:
- 上下文过长 (context too long)
- 上下文超出 (context exceeded)
- 上下文长度超 (context length exceeds)
- 超出最大上下文 (exceeds maximum context)
- 请压缩上下文 (please compress context)

Chinese characters are unaffected by toLowerCase() so check the
original message directly.

Closes openclaw#22849
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-compaction fails for non-English context overflow errors

2 participants