-
-
Notifications
You must be signed in to change notification settings - Fork 55.6k
Description
Bug Description
User and assistant messages containing certain phrases (like the two words "context" + "overflow" together) are incorrectly passed through sanitizeUserFacingText(), which rewrites them to error messages.
Steps to Reproduce
- Start a fresh session with
/new - Type a message containing "context" followed by "overflow" (as one phrase)
- Observe that the message is replaced with: "Context overflow: prompt too large for the model. Try again with less input or a larger-context model."
This happens even with minimal context usage (e.g., 8-15% of context window).
Expected Behavior
User messages should pass through unchanged. The sanitizeUserFacingText() function should only be applied to actual API error responses, not user/assistant chat messages.
Actual Behavior
Any message containing error-pattern phrases gets rewritten. This includes:
- User input messages
- Assistant responses (if they mention the phrase)
The bug affects both directions of chat.
Root Cause
In dist/agents/pi-embedded-helpers/errors.js:
export function sanitizeUserFacingText(text) {
// ...
if (isContextOverflowError(trimmed)) {
return ("Context overflow: prompt too large for the model. " +
"Try again with less input or a larger-context model.");
}
// ...
}And isContextOverflowError() matches on lower.includes("context overflow").
This function is being called somewhere in the message flow where it processes regular chat messages, not just error payloads.
Suggested Fix
Either:
- Add a flag/context to
sanitizeUserFacingText()to distinguish error payloads from regular messages - Or ensure this function is only called on actual API error responses, not on user/assistant message content
Environment
- Clawdbot version: npm latest 2026.1.24-3
- Model: claude-opus-4-5
- Channel: Telegram
Workaround
Avoid typing the exact phrase in messages until fixed.