Agents: scope error rewrites in sanitizeUserFacingText behind errorContext flag (#11649)#11685
Agents: scope error rewrites in sanitizeUserFacingText behind errorContext flag (#11649)#11685lailoo wants to merge 1 commit intoopenclaw:mainfrom
Conversation
Additional Comments (1)
Prompt To Fix With AIThis is a comment left during a code review.
Path: src/agents/tools/sessions-helpers.ts
Line: 392:392
Comment:
**Missing errorContext propagation**
`sanitizeUserFacingText()` now only performs error rewrites when `{ errorContext: true }`, but this callsite still invokes it as `sanitizeUserFacingText(joined)` (`src/agents/tools/sessions-helpers.ts:392`). If `joined` can ever contain error-origin text (e.g. persisted assistant messages representing failures, or subagent/tool error payloads stored as assistant text blocks), this will regress UI behavior by surfacing raw HTTP codes/JSON/error strings instead of the sanitized user-facing messages. Either ensure this path never processes error-context text, or propagate an equivalent error flag here (and any similar callsites).
How can I resolve this? If you propose a fix, please make it concise. |
|
Fixed in #12988. This will go out in the next OpenClaw release. If you still see this after updating to the first release that includes #12988, please open a new issue with:
Link back here for context. |
bfc1ccb to
f92900f
Compare
|
Closing as superseded by the merged sanitize/error-context work:
This PR’s intent appears covered by those merged changes and current mainline tests. |
Summary
Fixes #11649 (thorough fix)
This is the thorough fix for #11649, complementing the minimal fix in PR #11680 (length guard). Instead of relying on text length to distinguish errors from normal replies, this PR adds an explicit
errorContextflag so error-specific rewrites only run when the caller knows the text originates from an error.Problem
sanitizeUserFacingText()applies error-specific rewrites (billing, rate-limit, timeout, HTTP status, context overflow) to all text, including normal assistant replies. When the assistant discusses billing, credits, or payment topics, the sanitizer false-positives and replaces the entire reply.Reproduction & Verification
Used
scripts/reproduce-sanitize-false-positive.tsandscripts/verify-sanitize-false-positive.tsto call the actualsanitizeUserFacingText()function with real-world assistant reply text.Before fix (main branch) — Bug reproduced:
After fix — All verified:
Effect on User Experience
Before fix — user asks about billing, gets a canned error instead of the real answer: