Skip to content

stripInlineStatus collapses newlines in all incoming messages #32216

@rexkirshner

Description

@rexkirshner

Summary

stripInlineStatus() in src/auto-reply/reply/inline-status.ts unconditionally collapses all whitespace — including newlines — in every incoming message from authorized senders. This destroys paragraph structure before the message reaches the LLM.

Reproduction

  1. Send a multi-line Discord message (using Shift+Enter for line breaks) to an OpenClaw agent
  2. Check the session log — the message content has all \n characters replaced with single spaces

Root Cause

function stripInlineStatus(body) {
    const trimmed = body.trim();
    if (!trimmed) return { cleaned: "", didStrip: false };
    const cleaned = trimmed.replace(INLINE_STATUS_RE, " ").replace(/\s+/g, " ").trim();
    return { cleaned, didStrip: cleaned !== trimmed };
}

The .replace(/\s+/g, " ") matches \n, \r, \t, and all other whitespace characters, collapsing them into a single space. This runs unconditionally — even when the message contains no /status directive.

Impact

Any agent that needs to preserve the user's text formatting (journaling, note-taking, content recording) receives a wall of text instead of the user's intended paragraphs.

Suggested Fix

Replace /\s+/g with /[^\S\n]+/g to only collapse horizontal whitespace while preserving newlines:

const cleaned = trimmed.replace(INLINE_STATUS_RE, " ").replace(/[^\S\n]+/g, " ").trim();

Alternatively, only apply the whitespace normalization when the status regex actually matched.

Environment

  • OpenClaw version: 2026.2.19-2
  • Platform: Discord
  • Source file: src/auto-reply/reply/inline-status.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions