Skip to content

fix(slack,feishu,zalouser): multi-line /btw and /loop arguments arrive on one line - #185267

Closed
masatohoshino wants to merge 3 commits into
openclaw:mainfrom
masatohoshino:fix/slack-feishu-multiline-commands
Closed

masatohoshino wants to merge 3 commits into
openclaw:mainfrom
masatohoshino:fix/slack-feishu-multiline-commands

Conversation

@masatohoshino

@masatohoshino masatohoshino commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Closes #185266

What Problem This Solves

Fixes: in Slack, Feishu and Zalo Personal, a slash command with a multi-line argument (/btw with a pasted stack trace, a multi-line /loop prompt) reaches the command on one line, with its line breaks and indentation gone. In Zalo Personal this happens when the message mentions the bot.

User Impact

User impact: Slack, Feishu and Zalo Personal users can paste traces, code and lists into /btw, /side and /loop, and the model receives them as typed, as it already does in channels whose mention stripping runs in core.

Why This Change Was Made

#183606 made core stripMentions keep the whitespace of text that starts with /. These three channels build the command body in their own helpers (stripSlackMentionsForCommandDetection, normalizeFeishuCommandProbeBody and Zalo Personal's stripOwnMentionsForCommandBody), which strip mentions and then collapse every whitespace run to one space, so core never sees the line breaks. Each helper now applies the same rule as core: after mention stripping and trimming, text that starts with / keeps its whitespace; any other text is collapsed as before, so command detection for text like Please /help is unchanged.

Behavior note: a command followed by more lines (for example a mention, /stop and a second line) now reaches command matching with its line break, so these channels read it the way core already reads the same text since #183606.

Size: production +10/-10 lines in three helpers (the Zalo Personal one also drops an if around a slice that already returns an empty string past the end); tests +21/-2 lines (one new file beside the Slack helper, one case added to an existing Feishu inbound test, one test beside the existing Zalo Personal inbound normalization tests). No config, state or SDK surface changes.

Evidence

Tested at 844005b38fa (base upstream/main e68d5552923).

An isolated QA Gateway ran the real Slack plugin against a local fake Slack API with signed Events API deliveries; the model is the mock OpenAI provider, which records each request. The scenario sends a warmup DM (so the DM has a session), then this DM, and reads the /btw question from the recorded model request. Same scenario on both sides.

/btw QA-BTW-MULTILINE why does this fail?
  at first (a.ts:1)
    at second (b.ts:2)

Before (base e68d5552923):

Status: fail
model received the /btw question as "QA-BTW-MULTILINE why does this fail? at first (a.ts:1) at second (b.ts:2)"

After (this PR):

Status: pass
receivedQuestion: "QA-BTW-MULTILINE why does this fail?\n  at first (a.ts:1)\n    at second (b.ts:2)\n"

Observed result: before, the model received the stack trace joined into one line; after, it receives the three lines with their indentation.

Regression tests, one per channel, each failing on the base and passing with the fix:

  • Slack: the helper whose result becomes CommandBody (through textForCommandDetection) keeps the lines of a mention-prefixed multi-line /btw. prepare.test.ts already covers the collapse of non-command text (Please /help continue); it is over its line cap, so the new case sits beside the helper.
  • Feishu: a mention-prefixed multi-line /btw added to the existing DM command test in bot.test.ts, which checks CommandBody and BodyForCommands in the inbound context.
  • Zalo Personal: normalizeZaloInboundMessage keeps the lines in commandContent (the value monitor.ts passes as CommandBody) for a multi-line /btw that mentions the bot.

Checks: the touched tests (pnpm test <file> --maxWorkers=1, wall time per file at 844005b in the table below), plus extensions/feishu/src/sequential-key.test.ts, monitor.message-handler.ingress.test.ts, monitor.message-handler.debounce-policy.test.ts, extensions/slack/src/monitor/message-handler/prepare.test.ts, message-handler.test.ts, message-handler.debounce-policy.test.ts, and extensions/zalouser/src/monitor.group-gating.test.ts, ingress.test.ts, zalo-js.listener.test.ts; pnpm check:test-mock-exports, oxfmt --check and oxlint (type-aware) on the changed files, git diff --check; the broad suites run in this PR's CI.

Test file --maxWorkers=1 wall CI seconds
extensions/slack/src/monitor/commands.test.ts 2.3 s (1 test, Vitest 0.49 s) 1 ms of test time (1 test) in changed-extensions-config-3 (16 files, Vitest 91.84 s), CI run 40428675605 at 844005b
extensions/feishu/src/bot.test.ts 25.2 s (62 tests, Vitest 23.01 s) 19.64 s of test time (62 tests) in changed-extensions-config-5 (3 files, Vitest 26.51 s), CI run 40428675605 at 844005b
extensions/zalouser/src/zalo-quote-metadata.test.ts 10.0 s (12 tests, Vitest 7.87 s) 1.97 s of test time (12 tests) in changed-extensions-config-6 (6 files, Vitest 75.03 s), CI run 40428675605 at 844005b

bot.test.ts is an existing file of 62 tests; this PR adds one case to an existing DM command test.

Not covered, and why:

  • No run in a real Slack workspace: the author has no Slack workspace for this, and the maintained Slack e2e lane leases its workspace credentials from the maintainers' pool, which the author cannot use. The Slack run above drives the real Slack plugin and Gateway, but the Slack API is a local fake and the model is the mock provider. The mock provider records the request the Gateway sends, so the after run shows the exact /btw text a real model would receive; no real model was called.
  • No live Feishu or Zalo Personal run. The author has no Feishu tenant or Zalo account, and the QA harness has no local API for either. In each, the fix is the same rule in the helper that produces the command body, and its regression test checks the value passed on as CommandBody (for Zalo Personal, commandContent, which monitor.ts passes as CommandBody). For Feishu, that test goes through the inbound handler.

@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added channel: slack Channel integration: slack channel: zalouser Channel integration: zalouser channel: feishu Channel integration: feishu size: XS labels Oct 27, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 27, 2026
@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

Preserves multiline slash-command arguments after mention removal in Slack, Feishu, and Zalo Personal.

Example: Send a Slack message containing /btw why? at first (a.ts:1).

  • Before: The question becomes why? at first (a.ts:1).
  • After: The question retains why? at first (a.ts:1).

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The repair is focused and source-supported; supplied verification only partially exercises the required production boundary.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Pasted traces, code, and lists in multiline slash commands reach the model flattened onto one line.
Reason: Restores documented argument preservation through three existing channel boundaries without changing configuration or adding capability.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this PR narrowly repairs command text corruption still present on current main, and no introduced correctness defect was found.

Priority: P2
Reviewed head: 844005b38fad5fa68ca801c4ca0fd20a8e2bc284

Before merge

  • Add real behavior proof - At head 844005b, the supplied Slack Gateway trace demonstrates preserved command text reaching a recorded model request, but uses a fake Slack API and mock provider; Feishu and Zalo Personal have regression tests only. The earlier real-channel and real-model rank-up requirement remains unmet under root AGENTS.md. Add terminal captures or logs of those flows, redact IPs, API keys, phone numbers, and non-public endpoints, then update the body and request @clawsweeper re-review.

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted channel captures through an isolated Gateway and real agent/model showing preserved multiline arguments for Slack, Feishu, and a bot-mentioned Zalo Personal message.
Agent review details

How this fits together

Channel adapters remove mentions and produce command bodies that core command handlers pass to the agent.

flowchart LR
  A[Incoming channel message] --> B[Channel mention removal]
  B --> C[Preserved command body]
  C --> D[Core command handler]
  D --> E[Agent question or recurring prompt]
Loading

Technical review

Best possible solution:

Keep the existing channel normalizers and preserve slash-command whitespace immediately after their transport-specific mention removal.

Do we have a high-confidence way to reproduce the issue?

Current-main source deterministically collapses multiline input before dispatch in all three paths; the supplied Slack A/B trace independently demonstrates that mechanism, but no target code was executed during this review.

Is this the best way to solve the issue?

The patch is the smallest complete repair: each transport retains its existing mention owner and adopts the established core whitespace rule without new machinery.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 454004eab143.

Provenance checked

  • Slack command mention normalization changes intended behavior with a stated reason (fix(slack): detect control commands when message starts with @mention #14142: Recognize mention-prefixed control commands before command detection; later migration and normalization refactors retained that purpose.)
  • Feishu command projection changes intended behavior with a stated reason (b86bc9d: The helper was carried into a monitor-runtime split; later fix(feishu): preserve bot mentions across command admission #182441 preserved a separate mention-free command projection. The PR explains the narrow whitespace exception while retaining that separation.)
  • Zalo Personal own-mention removal changes intended behavior with a stated reason (fcdc1a1: The merged channel repair restored mention-aware group behavior; this PR preserves that removal and changes only whitespace handling for slash commands.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit b86bc9d adds extensions/feishu/src/bot-content.ts:294 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b86bc9de95d0; files: extensions/feishu/src/bot-content.ts)

PR surface

Source 0, Tests +19. Total +19 across 6 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 3 10 10 0
Tests 3 21 2 +19
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 31 12 +19

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #185266
Summary: This PR owns the remaining channel-local normalization failures; the merged core fix covers a different normalization owner.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Multiline command arguments are consistently corrupted on three channels, while ordinary messaging remains usable.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-27T01:03:39.269Z sha 844005b :: needs real behavior proof before merge. :: none

Reviewed October 30, 2026, 2:04 PM ET / 18:04 UTC (Revision 2).

@masatohoshino

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 30, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Thanks @masatohoshino for finding this and the focused repair! Landed the credited replacement in #190730 (2bd7edf), with multiline /btw and /loop regressions red on main and green after for all three channels. Single-line normalization is preserved. Closing this as superseded; your co-author credit is retained in the merged commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu channel: slack Channel integration: slack channel: zalouser Channel integration: zalouser P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slack, Feishu and Zalo Personal join the lines of a multi-line /btw or /loop into one line

2 participants