Skip to content

feat: openclaw message send --message-file <path> #79182

Description

@BigBot-ironlogic

Feature Request: --message-file flag for openclaw message send

Problem

When AI agents generate completion reports containing code blocks, JSON, multiline content, $ references, backticks, or quotes, passing them via shell expansion to --message causes:

  • Bad substitution errors (line 1: bad substitution)
  • Mangled or truncated messages
  • Silent send failures

Current workaround patterns are fragile and error-prone:

# Dangerous — shell interpolates $, backticks, quotes
openclaw message send --message "$(cat report.txt)"

# Also fragile — heredoc still subject to expansion
openclaw message send --message "$(cat << 'EOF'
$(cat report.txt)
EOF
)"

This means agent completion notifications — the primary way background tasks report back to users — are unreliable whenever output contains code.

Proposed Solution

Add a --message-file <path> flag to openclaw message send:

openclaw message send --channel telegram --target 8611381068 --message-file /tmp/report.txt

Acceptance Criteria

  • Reads file as UTF-8
  • Preserves multiline content exactly — no shell interpolation
  • Supports all existing routing flags (--channel, --target, --account, --reply-to, --thread-id)
  • Mutually exclusive with --message (error if both provided)
  • Handles max length: if file exceeds platform message limit, truncate with a trailing note ([truncated]) rather than silently dropping or failing
  • Returns nonzero exit code on send failure
  • Prints a clear error if the file does not exist or is not readable

Use Case

Agent completion notification pattern:

# Agent writes report to temp file
cat > /tmp/agent-report.txt << 'REPORT'
Done: Fixed 4 critical defects in LiveShiftForegroundService.kt
- Timer replaced with Handler (tick loop survives exceptions)
- foregroundServiceType changed from dataSync to health (6h limit removed)
- PARTIAL_WAKE_LOCK acquired on shift start (Doze fix)
- startForeground() moved to onCreate() (ANR window closed)
REPORT

# Safe send — no shell expansion risk
openclaw message send --channel telegram --target 8611381068 --message-file /tmp/agent-report.txt

Context

Discovered during Log-it Android service fix where two background Claude Code agents completed their work but failed to send Telegram completion notifications due to shell expansion issues in the completion prompt.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions