Skip to content

fix(feishu): preserve bot mentions across command admission - #182441

Merged
steipete merged 1 commit into
mainfrom
steipete/fix-72504
Oct 25, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/fix-72504

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: the agent loses track of which bot was addressed when Feishu strips the receiving bot's own mention from the message in multi-bot conversations.

User Impact

The agent now receives the full mention context in groups and DMs, while command matching, authorization, debounce admission, sequential routing, and mention-prefixed /stop and /btw behave as before.

Why This Change Was Made

The shared mention renderer mixed the agent-facing message with command parsing, so stripping the bot mention for commands also hid it from the agent. The renderer now keeps all mentions, and only the separate command projection is normalized at the parser consumers and command-decision owners, including transcribed-audio probes. For cross-app bot events, the existing local API verification still decides whether the receiving bot was addressed, and only that verified identity is rendered; the restriction on other recipients and admission policy are unchanged, and the duplicated event clone/reparse path is removed. No config, SDK, protocol, schema, dependency, or authorization-policy change.

This continues closed PR #117906, rebuilt on current main with the missing command, debounce, and verified-identity coverage. Production LOC +28/-33; tests +148/-45; docs +2/-0.

Evidence

  • Red on main: 5 expected failures covering preserved DM and group agent bodies, separate command bodies, and the locally verified cross-app receiving-bot identity.
  • Green: 124/124 across eight owning and consumer test files, including existing rejection of unverifiable bot identities and other app-scoped recipients, plus a real receive, debounce, and sequential regression that holds an ordinary turn, admits mentioned /stop and /btw immediately, and then checks ordinary-message FIFO order.
  • Targeted typecheck, oxfmt, the line-cap ratchet, docs listing, and git diff --check passed; oxlint reports no new diagnostics (one existing no-redundant-type-constituents finding on the broadcast agentClaim union reproduces unchanged on main).
  • pnpm prompt:snapshots:gen left all six generated files byte-identical (snapshot token delta 0); per-message content now includes the receiving-bot mention, sized by the incoming event.
  • Independent review: clean, no actionable findings.
  • Gap: no live multi-bot Feishu or Gateway run; the synthetic tests prove the agent input and control admission but not that a live model answers instead of choosing NO_REPLY, so PR CI remains the broad proof.

Fixes #72504

@clawsweeper

clawsweeper Bot commented Oct 24, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T19:56:05.321412Z 2bd7aa2 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: feishu Channel integration: feishu size: M labels Oct 24, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 20d87f4b32

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

inboundHistory,
rawBody: commandFacingContent,
commandBody: commandFacingContent,
commandBody: effectiveCommandProbeBody,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve command arguments when removing bot addressing

For Feishu commands containing multiline or whitespace-sensitive arguments, passing effectiveCommandProbeBody as the actual command body corrupts the payload: normalizeFeishuCommandProbeBody() collapses all whitespace and removes mentions throughout the text. For example, /btw explain this Python:\ndef f():\n return 1 reaches the side-question handler as /btw explain this Python: def f(): return 1. The inbound context builder assigns this value to both CommandBody and BodyForCommands, so retaining the original RawBody does not recover the arguments. This also defeats the explicit argument-preservation behavior for skills and free-text commands in src/auto-reply/commands-registry-normalize.ts. Keep the lossy projection for admission checks, but remove addressing from the dispatched command body without rewriting its arguments.

Useful? React with 👍 / 👎.

@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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 24, 2026
@clawsweeper

clawsweeper Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

Preserve receiving-bot mentions in agent context while deriving separate command input for Feishu admission and routing.

Example: A group message mentions Bot A (ou_a) and Bot B (ou_b), followed by hello, and Bot A receives it.

  • Before: Agent text contains Bot B's mention but omits Bot A's mention.
  • After: Agent text contains both <at user_id="ou_a">Bot A</at> and <at user_id="ou_b">Bot B</at>.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The approved repair direction has focused boundary coverage, but command arguments are corrupted and an affected consumer test fails.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its evidence exercises the parser and receive/debounce/sequential owners in process, and explicitly discloses that no live Feishu or Gateway multi-bot run was performed.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A bot explicitly addressed alongside another Feishu bot receives agent text that omits its own mention and can consequently stay silent.
Reason: The issue has a concrete source failure and reporter context, and recorded maintainer direction approves preserving agent mentions while retaining command behavior.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep this maintainer-authored PR open: it addresses a current Feishu defect, but introduces command-argument corruption and leaves a related CI assertion outdated.

Priority: P2
Reviewed head: 20d87f4b323ad616ca321a4951dbdec219add647

Before merge

  • Preserve command arguments when removing bot addressing (P2) - Assigning effectiveCommandProbeBody here sends the lossy detection projection into command execution. normalizeFeishuCommandProbeBody collapses all whitespace and removes mentions throughout the text, so even an unmentioned DM containing /btw explain this Python:\ndef f():\n return 1 becomes /btw explain this Python: def f(): return 1; mention arguments are also removed. The context builder copies this value into both CommandBody and BodyForCommands, bypassing the argument-preserving behavior in commands-registry-normalize.ts. Keep the probe for classification and derive the dispatched body by removing addressing without rewriting the argument tail.
  • Update the batching regression to expect preserved self mentions (P2) - The normalizer change also affects the existing registered-monitor batching test, whose expected content still removes ou_bot from both constituent messages. The exact-head changed-extensions CI annotation reports this assertion failure at line 402. Update that expectation to retain each receiving-bot mention while preserving the existing checks for literal placeholder-like display names, per-message identity, and forwarding targets; restoring stripping would undo the intended fix.

Findings

  • [P2] Preserve command arguments when removing bot addressing — extensions/feishu/src/bot.ts:1287
  • [P2] Update the batching regression to expect preserved self mentions — extensions/feishu/src/monitor.reaction.test.ts:402-403

Tests

  • Missing end-to-end proof: The supplied tests exercise parsing and receive admission, but no live Feishu multi-bot turn demonstrates preserved context producing a reply.
Agent review details

How this fits together

Feishu events pass through debounce and sequential routing into message parsing, authorization, and inbound context construction, which supplies separate agent and command bodies.

flowchart TD
  A[Feishu event] --> B[Debounce admission]
  B --> C[Sequential routing]
  C --> D[Parse and authorize]
  D --> E[Agent mention context]
  D --> F[Command body]
  E --> G[Agent dispatch]
  F --> H[Command execution]
Loading

Technical review

Best possible solution:

Keep full agent mention context, remove only command addressing without altering arguments, and update the affected batching assertion.

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

Current-main source deterministically removes the receiver's mention; the reported model NO_REPLY outcome was not reproduced, and no target code was executed during this read-only review.

Is this the best way to solve the issue?

Separating agent context from command detection respects the historical command contract, but a lossy detection probe cannot serve as the executable command payload.

Full review comments:

  • [P2] Preserve command arguments when removing bot addressing — extensions/feishu/src/bot.ts:1287
    Assigning effectiveCommandProbeBody here sends the lossy detection projection into command execution. normalizeFeishuCommandProbeBody collapses all whitespace and removes mentions throughout the text, so even an unmentioned DM containing /btw explain this Python:\ndef f():\n return 1 becomes /btw explain this Python: def f(): return 1; mention arguments are also removed. The context builder copies this value into both CommandBody and BodyForCommands, bypassing the argument-preserving behavior in commands-registry-normalize.ts. Keep the probe for classification and derive the dispatched body by removing addressing without rewriting the argument tail.
    Confidence: 0.99
  • [P2] Update the batching regression to expect preserved self mentions — extensions/feishu/src/monitor.reaction.test.ts:402-403
    The normalizer change also affects the existing registered-monitor batching test, whose expected content still removes ou_bot from both constituent messages. The exact-head changed-extensions CI annotation reports this assertion failure at line 402. Update that expectation to retain each receiving-bot mention while preserving the existing checks for literal placeholder-like display names, per-message identity, and forwarding targets; restoring stripping would undo the intended fix.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Self-mention removal for command recognition changes intended behavior with a stated reason (fix(feishu): strip bot mention in group context so slash commands are recognized #36016: Group messages beginning with a bot mention prevented slash-command interception; the earlier change extended stripping from DMs to groups.)
  • Single-pass normalization and prepared batched content keeps the original intent (6f848b3: Prevent overlapping mention keys, placeholder-like names, and batching metadata from corrupting rendered identity.)
  • Shared normalizer placement changes intended behavior with a stated reason (7b41658: Reuse the single-pass normalizer for fetched, quoted, threaded, and forwarded text without changing incoming-event behavior.)
  • Cross-app bot mention verification keeps the original intent (3e83878: Require local-app verification of mismatched recipient identities and reject unverifiable bot events before dispatch.)
  • Independent stop and btw lanes keeps the original intent (4b4ec4d: Allow interrupt and side-question commands to bypass active ordinary turns while preserving ordinary-message FIFO.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test extensions/feishu/src/bot.test.ts extensions/feishu/src/bot.helpers.test.ts extensions/feishu/src/monitor.message-handler.ingress.test.ts extensions/feishu/src/monitor.reaction.test.ts extensions/feishu/src/sequential-key.test.ts
  • pnpm exec oxfmt --check extensions/feishu/src/bot.ts extensions/feishu/src/bot-content.ts extensions/feishu/src/bot.test.ts extensions/feishu/src/monitor.reaction.test.ts
  • git diff --check
  • Verify multiline command payloads remain byte-preserved after addressing removal and mention-prefixed stop/btw retain their independent admission lanes.

What I checked:

Likely related people:

  • Sliverp: Raw commit 6f848b3 adds extensions/feishu/src/bot.ts:175 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6f848b351e8c; files: extensions/feishu/src/bot.ts)
  • Leon-SK668: Raw commit 7b41658 adds extensions/feishu/src/mention.ts:34 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 7b41658157cf; files: extensions/feishu/src/mention.ts)
  • Nimrod Gutman: Raw commit 4b4ec4d adds extensions/feishu/src/sequential-key.ts:12 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4b4ec4dbc298; files: extensions/feishu/src/sequential-key.ts)

PR surface

Source -5, Tests +103, Docs +2. Total +100 across 9 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 28 33 -5
Tests 4 148 45 +103
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 178 78 +100

Labels

Label changes:

  • add P2: The repair addresses channel-specific mention-context loss, with a command-payload regression and a narrowly attributable test failure to resolve.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: The repair addresses channel-specific mention-context loss, with a command-payload regression and a narrowly attributable test failure to resolve.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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.

Reviewed October 24, 2026, 4:55 AM ET / 08:55 UTC.

Keep receiving-bot mentions in agent-facing message content, and derive command probes at each decision owner. Preserve abort and btw admission through receive debouncing and sequential routing. Render only locally verified receiving-bot identity for app-scoped bot events, keeping additional recipient restrictions unchanged.
@steipete
steipete merged commit 045b647 into main Oct 25, 2026
97 checks passed
@steipete
steipete deleted the steipete/fix-72504 branch October 25, 2026 00:53
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
…#182441)

Keep receiving-bot mentions in agent-facing message content, and derive command probes at each decision owner. Preserve abort and btw admission through receive debouncing and sequential routing. Render only locally verified receiving-bot identity for app-scoped bot events, keeping additional recipient restrictions unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feishu: bot strips its own <at> mention causing NO_REPLY in multi-bot groups

1 participant