Raise chat.history text cap to avoid premature truncation#1286
Open
BingqingLyu wants to merge 2 commits into
Open
Raise chat.history text cap to avoid premature truncation#1286BingqingLyu wants to merge 2 commits into
BingqingLyu wants to merge 2 commits into
Conversation
Address the non-ASCII chat.history regression by adding a byte-aware fallback to text truncation. Keep long UTF-8 replies readable instead of replacing them with the oversized placeholder, and cover the behavior with a regression test for emoji-heavy assistant text.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Raise the
chat.historytext cap from12_000to64_000and make truncation UTF-8 byte-aware so long assistant replies stay readable instead of being replaced by the oversized placeholder.What changed
CHAT_HISTORY_TEXT_MAX_CHARSinsrc/gateway/server-methods/chat.tsfrom12_000to64_000truncateChatHistoryText()so UTF-8-heavy text is truncated to a safe prefix before the128 * 1024single-message byte guard runs[chat.history omitted: message too large]Why
Before this change,
chat.historytruncatedcontent[].text,partialJson,arguments, andthinkingat 12k characters before the larger byte-budget logic ran.Raising the char cap alone fixes premature truncation for long ASCII replies, but it leaves a second failure mode: long UTF-8-heavy text can bypass the char cap and then be replaced entirely by the oversized placeholder during the later byte-budget pass.
This update fixes both paths:
Test
pnpm -C /tmp/openclaw-pr-53243 exec vitest run --config vitest.gateway.config.ts src/gateway/server.chat.gateway-server-chat-b.test.tsFixes openclaw#53242