Agents: scope sanitizeUserFacingText rewrites to errorContext#12988
Merged
Takhoffman merged 3 commits intomainfrom Feb 10, 2026
Merged
Agents: scope sanitizeUserFacingText rewrites to errorContext#12988Takhoffman merged 3 commits intomainfrom
Takhoffman merged 3 commits intomainfrom
Conversation
Contributor
Additional Comments (1)
Also appears in: Prompt To Fix With AIThis is a comment left during a code review.
Path: src/agents/pi-embedded-utils.ts
Line: 221:223
Comment:
**Missed errorContext propagation**
`sanitizeUserFacingText()` now gates its error-pattern rewrites behind `opts.errorContext`, but this call site still uses the default (`false`). If `extractAssistantText()` can ever be used on provider error strings (or on assistant messages that contain raw error payloads that should be normalized), those rewrites will no longer happen and the UI will show the raw payload instead of the friendly formatted message. This looks inconsistent with the other updated call sites that thread `payload.isError`.
Also appears in: `src/agents/tools/sessions-helpers.ts:393` (transcript extraction path).
How can I resolve this? If you propose a fix, please make it concise. |
This was referenced Feb 10, 2026
Open
This was referenced Feb 10, 2026
trevorgordon981
pushed a commit
to trevorgordon981/openclaw
that referenced
this pull request
Feb 10, 2026
lucasmpramos
pushed a commit
to butley/openclaw
that referenced
this pull request
Feb 10, 2026
ProgramCaiCai
pushed a commit
to ProgramCaiCai/openclaw
that referenced
this pull request
Feb 10, 2026
Hansen1018
pushed a commit
to Hansen1018/openclaw
that referenced
this pull request
Feb 10, 2026
michaelleone
pushed a commit
to michaelleone/openclaw
that referenced
this pull request
Feb 11, 2026
This was referenced Feb 11, 2026
skyhawk14
pushed a commit
to skyhawk14/openclaw
that referenced
this pull request
Feb 13, 2026
maximalmargin
added a commit
to maximalmargin/openclaw
that referenced
this pull request
Feb 17, 2026
Fixes openclaw#19258 sanitizeUserFacingText was rewriting normal assistant replies containing words like 'billing' or 'payment' into error messages, even when there was no actual API error. The root cause was an unconditional shouldRewriteBillingText check that ran on ALL text, not just errors. This was a leftover from before the errorContext scoping was added in openclaw#12988. The billing error pattern is already correctly handled inside the errorContext block (line 542), so the outer check was redundant and harmful. Changes: - Removed shouldRewriteBillingText call outside errorContext - Removed unused shouldRewriteBillingText function (dead code) Now billing error rewrites only happen when errorContext=true, preventing false positives when users legitimately discuss billing/payment topics.
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
Fix false positives where normal assistant prose containing error-like phrases (e.g. "Context overflow") gets rewritten/swallowed on outbound channel delivery.
Repro Steps
Root Cause
sanitizeUserFacingText()was applying keyword-based error rewrites to normal assistant text during outbound normalization.Behavior Changes
sanitizeUserFacingText()now require explicit error context.ReplyPayload.isError.Codebase and GitHub Search
sanitizeUserFacingText,isContextOverflowError,shouldRewriteContextOverflowText,normalizeReplyPayload,extractAssistantText.Tests
pnpm buildpnpm checkpnpm testManual Testing
Sign-Off
References
Issues: #12889 #12309 #3594 #7483 #10094 #10368 #11317 #11359 #11649 #12022 #12432 #12676 #12711
PRs: #7567 #10220 #10601 #10620 #10760 #11680 #11685 #12052 #12226 #12433 #12702 #12720 #12726 #12777