Skip to content

fix: strip leading empty lines in sanitizeUserFacingText#16280

Merged
steipete merged 3 commits intomainfrom
land/16158-strip-leading-empty-lines
Feb 14, 2026
Merged

fix: strip leading empty lines in sanitizeUserFacingText#16280
steipete merged 3 commits intomainfrom
land/16158-strip-leading-empty-lines

Conversation

@steipete
Copy link
Copy Markdown
Contributor

@steipete steipete commented Feb 14, 2026

Ports #16158 to a maintainer branch, strips leading empty lines (not full trimStart) and normalizes whitespace-only outputs to empty.

Thanks @mcinteerj.

Greptile Overview

Greptile Summary

Refines sanitizeUserFacingText to strip only leading blank lines instead of all leading whitespace. This preserves indentation on the first content line (important for markdown/code blocks) while still removing spurious empty lines from LLM output.

  • src/agents/pi-embedded-helpers/errors.ts: Replaces .trimStart() with a regex (/^(?:[ \t]*\r?\n)+/) that removes leading blank/whitespace-only lines without clobbering first-line indentation. Also reorders the operation to strip leading lines before passing to collapseConsecutiveDuplicateBlocks.
  • Test update: Adjusts one test case to reflect that leading spaces on the first content line are now intentionally preserved.
  • CHANGELOG: Updates wording from "strip leading whitespace/newlines" to "strip leading empty lines" to match the actual behavior.

Confidence Score: 5/5

  • This PR is safe to merge — it's a focused, well-scoped behavior refinement with correct regex logic and updated tests.
  • The change is minimal and targeted: a single regex replacement that is more precise than the previous .trimStart(). The regex is correct, the test was updated to reflect the new behavior, and the CHANGELOG accurately describes the change. No callers are affected negatively — the only observable difference is that leading indentation on the first content line is now preserved, which is the intended improvement.
  • No files require special attention.

Last reviewed commit: 5d29c8f

@cursor
Copy link
Copy Markdown

cursor bot commented Feb 14, 2026

PR Summary

Low Risk
Small, well-covered string-sanitization change affecting only user-facing text formatting; main risk is minor whitespace/formatting differences in rendered assistant output.

Overview
Tightens sanitizeUserFacingText so it removes only leading empty/whitespace-only lines instead of using trimStart(), preserving indentation on the first content line (e.g., code blocks/markdown) while still collapsing consecutive duplicate blocks.

Updates the sanitize E2E coverage to match the new behavior and tweaks the CHANGELOG.md entry wording accordingly.

Written by Cursor Bugbot for commit 5d29c8f. This will update automatically on new commits. Configure here.

@openclaw-barnacle openclaw-barnacle bot added agents Agent runtime and tooling size: XS maintainer Maintainer-authored PR labels Feb 14, 2026
@steipete steipete merged commit 50a6e0e into main Feb 14, 2026
15 checks passed
@steipete steipete deleted the land/16158-strip-leading-empty-lines branch February 14, 2026 15:34
hamidzr pushed a commit to hamidzr/openclaw that referenced this pull request Feb 14, 2026
)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)
mcinteerj added a commit to mcinteerj/openclaw that referenced this pull request Feb 14, 2026
The block streaming delivery path (onBlockReply) bypasses
sanitizeUserFacingText, so the trimStart fix from openclaw#16158/openclaw#16280
doesn't apply to users with blockStreaming enabled (the default).

Adds trimStart() to the cleaned text in the block reply payload
construction, consistent with the non-streaming path.
mcinteerj added a commit to mcinteerj/openclaw that referenced this pull request Feb 14, 2026
The block streaming delivery path (onBlockReply) bypasses
sanitizeUserFacingText, so the trimStart fix from openclaw#16158/openclaw#16280
doesn't apply to users with blockStreaming enabled (the default).

Adds trimStart() to the cleaned text in the block reply payload
construction, consistent with the non-streaming path.
mverrilli pushed a commit to mverrilli/openclaw that referenced this pull request Feb 14, 2026
)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)
akoscz pushed a commit to akoscz/openclaw that referenced this pull request Feb 15, 2026
)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)
sebslight pushed a commit to mcinteerj/openclaw that referenced this pull request Feb 15, 2026
The block streaming delivery path (onBlockReply) bypasses
sanitizeUserFacingText, so the trimStart fix from openclaw#16158/openclaw#16280
doesn't apply to users with blockStreaming enabled (the default).

Adds trimStart() to the cleaned text in the block reply payload
construction, consistent with the non-streaming path.
GwonHyeok pushed a commit to learners-superpumped/openclaw that referenced this pull request Feb 15, 2026
)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)
snowzlm pushed a commit to snowzlm/openclaw that referenced this pull request Feb 15, 2026
)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 1, 2026
)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)

(cherry picked from commit 50a6e0e)

# Conflicts:
#	CHANGELOG.md
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 3, 2026
)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)

(cherry picked from commit 50a6e0e)

# Conflicts:
#	CHANGELOG.md
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)

* fix: strip leading empty lines in sanitizeUserFacingText (openclaw#16158) (thanks @mcinteerj)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant