Skip to content

Discord auto-replies ignore configured maxLinesPerMessage and re-split at default 17 lines #41017

@rbutera

Description

@rbutera

[Bug]: Discord auto-replies ignore configured maxLinesPerMessage and re-split at default 17 lines

Bug type

Behavior bug (incorrect output/state without crash)

Summary

Discord auto-replies are re-chunked at the default 17-line limit even when channels.discord.maxLinesPerMessage is explicitly set higher (for example 120) in config.

Steps to reproduce

  1. Configure Discord with:
    • channels.discord.maxLinesPerMessage: 120
    • and/or channels.discord.accounts.<account>.maxLinesPerMessage: 120
  2. Use a Discord-bound OpenClaw agent account.
  3. Send the agent a prompt that causes a multi-paragraph reply longer than 17 visible lines but shorter than 120 lines.
  4. Observe the outbound reply in Discord.
  5. Trace the delivery path through:
    • src/discord/monitor/message-handler.process.ts
    • src/discord/monitor/reply-delivery.ts
    • src/discord/send.shared.ts

Expected behavior

A reply shorter than the configured maxLinesPerMessage value should be sent as a single Discord message, or at least should not be re-split using the default 17-line fallback.

Actual behavior

The reply is chunked once with the configured value, then re-chunked in the optimized send path with no maxLinesPerMessage passed through. That second pass falls back to the hardcoded default of 17 lines, so replies are split into ~17-line Discord messages.

OpenClaw version

2026.3.7

Operating system

Linux 6.6.87.2-microsoft-standard-WSL2 (x64) / Windows 11 host

Install method

Local source checkout / dev runtime

Logs, screenshots, and evidence

Config checked in ~/.openclaw/openclaw.json:
- channels.discord.maxLinesPerMessage = 120
- channels.discord.accounts.default.maxLinesPerMessage = 120
- channels.discord.accounts.hermione.maxLinesPerMessage = 120
- channels.discord.accounts.heimer.maxLinesPerMessage = 120

Relevant source:

src/discord/chunk.ts
  const DEFAULT_MAX_LINES = 17;

src/discord/monitor/reply-delivery.ts
  deliverDiscordReply(...) correctly chunks with:
    chunkDiscordTextWithMode(text, {
      maxChars: chunkLimit,
      maxLines: params.maxLinesPerMessage,
      chunkMode: mode,
    })

  But sendDiscordChunkWithFallback(...) fast path calls:
    sendDiscordText(rest, channelId, text, params.replyTo, request)

  Missing pass-through args:
    - maxLinesPerMessage
    - chunkMode

src/discord/send.shared.ts
  sendDiscordText(...) calls buildDiscordTextChunks(...)
  which falls back to DEFAULT_MAX_LINES when maxLinesPerMessage is undefined.

Result:
- first delivery pass respects configured maxLinesPerMessage
- second delivery pass re-splits at default 17 lines

Impact and severity

Affected: Discord-bound OpenClaw agent replies, likely across any account using the fast-path delivery path
Severity: Medium to High (does not crash, but breaks reply formatting and makes long answers noisy and harder to read)
Frequency: 100% when a reply chunk exceeds 17 lines and goes through the fast path
Consequence: Replies are fragmented into many smaller Discord messages, config appears ignored, and debugging is misleading because the visible config is correct

Additional information

Related: #40128

This appears to be a separate surviving bug even if #40128 addressed earlier config propagation concerns.

Likely fix:

  • add maxLinesPerMessage and chunkMode to sendDiscordChunkWithFallback(...)
  • pass both through to sendDiscordText(...)
  • add a regression test proving the fast path does not re-split a chunk that is already valid under the configured line limit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions