-
-
Notifications
You must be signed in to change notification settings - Fork 79.1k
Bug: chat.history truncates long assistant messages at 12k chars even when they fit the history budget #53242
Copy link
Copy link
Closed as not planned
BingqingLyu/openclaw
#1286Closed as not planned
Copy link
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.Channel message delivery can be lost, duplicated, or misrouted.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.Channel message delivery can be lost, duplicated, or misrouted.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Summary
chat.historytruncates long assistant text far too aggressively in WebChat / Control UI. Messages that still fit comfortably within the configured history byte budget and the single-message byte cap are being cut at 12,000 chars and returned with...(truncated)....This shows up in practice as apparently truncated tutor / teaching responses after upgrading OpenClaw, even when the session is otherwise healthy.
Current behavior
In
src/gateway/server-methods/chat.ts,truncateChatHistoryText()applies a hard per-text-field cap of12_000chars:content[].textpartialJsonargumentsthinkingThat truncation happens before the larger history payload budget is applied. So a single long assistant response can be cut down even though:
CHAT_HISTORY_MAX_SINGLE_MESSAGE_BYTESis128 * 1024Why this is a bug
The current cap is much smaller than the surrounding byte budgets and causes premature truncation of normal long-form responses in WebChat / Control UI. The UI then only ever receives the already-truncated text.
This is especially visible for workflows that intentionally produce long, structured answers.
Reproduction
chat.historypayload still fits within the configured history byte budget.chat.history.Actual
The returned message text is truncated at 12k chars and includes
...(truncated)....Expected
If the message fits within the history byte budget and does not exceed the oversized single-message threshold,
chat.historyshould return the full text.Proposed fix
Raise
CHAT_HISTORY_TEXT_MAX_CHARSto64_000. This is still conservative relative to the 128 KB single-message cap, but avoids cutting normal long-form assistant answers in half.I have a companion PR with:
12_000to64_000