Skip to content

fix(feishu): preserve mentions in single and batched messages - #96311

Merged
steipete merged 3 commits into
mainfrom
fix/feishu-mention-longest-first
Sep 5, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/feishu-mention-longest-first

Conversation

@sliverp

@sliverp sliverp commented Jun 24, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Feishu messages mentioning several people can reach the agent with missing or incorrect names. Short mention keys can consume longer keys, and later replacements can corrupt display names that contain another mention key. Combining consecutive messages can repeat the corruption using the last message's mention metadata.

Why This Change Was Made

Normalize mention keys in one pass, then carry the prepared text separately through message batching, queue selection, and event parsing. This removes the old path that encoded already-normalized text back into a raw event and interpreted it again. Original message identity and mention metadata remain the source for deduplication, addressing, and forwarding.

This supersedes the closed word-boundary alternative #96284 while preserving valid mentions followed directly by text. The original longest-first fix is retained as part of a complete single-pass solution. Its standalone helper tests are consolidated into the existing parser and batching suites. Contributor Sliverp (@sliverp)'s ancestry and credit are preserved.

User Impact

Individual and combined messages preserve readable names and their intended references. Display names containing placeholder-like text remain literal. Existing bot-addressing, mention-forward recipients, and message delivery identity retain their metadata-based behavior.

Evidence

Secretless GitHub-hosted proof exercised SDK HTTP ingress, the production receive handler and core channel turn/session/reply flow, and actual SDK HTTPS delivery to a controlled synthetic API. TLS verification remained enabled. The provider was an existing per-instance mock.

The baseline failed the prefix-sharing case. A longest-first-only variant still failed literal names. The single-pass normalizer alone still failed ordered batching; the full candidate passed default and batched direct/group flows with exact native mention elements, exact model-output bytes, one HTTPS receipt per turn, and preserved message/recipient identities. All 185 tests across six suites passed.

The nine final source/test files matched the hosted candidate before repository-pinned formatting; subsequent changes are layout and the equivalent repository-required copying sort on a freshly created key array. The pinned Lark SDK 1.73.0 event types were inspected directly: placeholder keys, display names, and identifiers are separate fields. Independent Codex review through P2 found no actionable defects.

This is controlled SDK/channel-runtime/transport proof. It does not claim an authenticated upstream Feishu service, native client UI, or Gateway-daemon run.

Production: +35/-21 (net +14). Tests: +103/-14 (net +89). Production growth carries prepared content across the owning boundary and includes formatter line wrapping; the obsolete raw-event rewrite is removed. Rewriting per-message raw keys would add complexity and change transport metadata, while downstream string guards would leave the producer error intact. The Feishu guide also clarifies readable mentions in combined messages. No configuration, database schema, public SDK export, or dependency is added.

Maintainer verification of linked evidence

Maintainer verification for the latest review's retrieval limitation: I downloaded and inspected the hosted artifacts, including the actual default and batched direct/group transport outputs and 185 passing tests. The recorded failures and candidate successes come from those logs, not solely the PR narrative. The candidate files were also compared against the downloaded patch before formatting; the later copying-sort change preserves ordering on the newly created key array, and exact-head CI33990117811 is green.

I also downloaded the exact Lark SDK 1.73.0 package, verified its SHA512 against registry metadata, and directly inspected its receive-event types. They separate message content, mention key, structured identifier, and display name. This closes the reviewer-specific exact-package/artifact retrieval gap. The proof remains a controlled synthetic API/provider flow; authenticated upstream Feishu and native UI coverage are not claimed. No code or gate change is needed for this disposition.

@openclaw-barnacle openclaw-barnacle Bot added channel: feishu Channel integration: feishu size: XS maintainer Maintainer-authored PR labels Jun 24, 2026
@sliverp
sliverp force-pushed the fix/feishu-mention-longest-first branch from 4d85df3 to e201416 Compare June 24, 2026 06:42
@clawsweeper

clawsweeper Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 5, 2026, 4:40 PM ET / 20:40 UTC.

ClawSweeper review

What this changes

The Feishu plugin expands mention placeholders in one pass and carries prepared text through batching so names and references remain intact.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR remains useful: current main and v2026.9.2 retain the faulty replacement loop. The expanded repair addresses both single-message and batching corruption, with no blocking source findings.

Priority: P2
Reviewed head: 17eca5c278301ff1c1a56f938e068b51ee5c3e77

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with meaningful regression coverage and recorded transport proof; no actionable patch defect was found.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (linked_artifact): The captured evidence reports SDK ingress through the production Feishu receive/core-turn owners and real HTTPS delivery to a controlled service, with exact mentions and identities preserved after single and batched direct/group turns. This supports the changed path; the hosted artifact was not independently retrievable, and authenticated upstream Feishu coverage is not claimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The captured evidence reports SDK ingress through the production Feishu receive/core-turn owners and real HTTPS delivery to a controlled service, with exact mentions and identities preserved after single and batched direct/group turns. This supports the changed path; the hosted artifact was not independently retrievable, and authenticated upstream Feishu coverage is not claimed.
Evidence reviewed 10 items Introduced repair: The pinned base-to-head diff replaces sequential substitutions with one longest-first expression, removes the prepared-text-to-raw-event rewrite, and passes prepared content to parsing and queue selection.
Current main still needs the fix: Current main still replaces each mention separately, allowing a short key to consume a longer key and later substitutions to reinterpret inserted display names. The four affected production files also match the pinned PR base.
Released behavior: The latest supplied release, v2026.9.2, also contains the sequential replacement loop; this review does not identify a shipped fix.
Findings None None.
Security None None.

How this fits together

The Feishu plugin converts incoming chat events into agent messages and routes replies back to the conversation. Mention normalization prepares readable text while event metadata controls addressing, forwarding, and duplicate suppression.

flowchart LR
  A[Feishu message events] --> B[Parse text and mention metadata]
  B --> C[Expand placeholders once]
  C --> D[Combine consecutive messages]
  D --> E[Select message queue]
  E --> F[Agent turn and reply]
  A --> G[Original identity and addressing]
  G --> F
Loading

Before merge

  • Resolve merge risk (P1) - Reviewer verification is limited to the captured transport-proof account: the hosted artifact and exact Lark SDK 1.73.0 package could not be retrieved, although current upstream event types corroborate the relevant contract.
Agent review details

Security

None.

PR surface

Source +14, Tests +89, Docs +3. Total +106 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 4 35 21 +14
Tests 5 103 14 +89
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 141 35 +106

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +14; tests net +89; docs +3 Production growth carries prepared content through existing owners and removes the corrupting raw-event rewrite; tests protect distinct parser, batching, routing, and identity failures.

Root-cause cluster

Relationship: canonical
Canonical: #96311
Summary: This PR retains the useful prefix-collision repair and covers the additional literal-name and batching failures.

Members:

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

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the single-pass normalizer and separate prepared-text handoff; the small production increase preserves raw event identity without introducing another normalization path.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the single-pass normalizer and separate prepared-text handoff; the small production increase preserves raw event identity without introducing another normalization path.

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

Yes, from source: processing @_user_1 before @_user_10 corrupts the longer reference, and batching reinterprets already-expanded names. Focused regression cases and recorded before/after proof cover both; this reviewer did not execute them.

Is this the best way to solve the issue?

Yes. Fixing substitution at its owner and carrying prepared text avoids repeated interpretation; longest-first substitution alone still corrupts literal names, while word boundaries reject valid mentions immediately followed by text.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The captured evidence reports SDK ingress through the production Feishu receive/core-turn owners and real HTTPS delivery to a controlled service, with exact mentions and identities preserved after single and batched direct/group turns. This supports the changed path; the hosted artifact was not independently retrievable, and authenticated upstream Feishu coverage is not claimed.

Label justifications:

  • P2: This repairs a bounded Feishu mention-corruption bug affecting the text delivered to agents.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The captured evidence reports SDK ingress through the production Feishu receive/core-turn owners and real HTTPS delivery to a controlled service, with exact mentions and identities preserved after single and batched direct/group turns. This supports the changed path; the hosted artifact was not independently retrievable, and authenticated upstream Feishu coverage is not claimed.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured evidence reports SDK ingress through the production Feishu receive/core-turn owners and real HTTPS delivery to a controlled service, with exact mentions and identities preserved after single and batched direct/group turns. This supports the changed path; the hosted artifact was not independently retrievable, and authenticated upstream Feishu coverage is not claimed.

Evidence

What I checked:

  • Introduced repair: The pinned base-to-head diff replaces sequential substitutions with one longest-first expression, removes the prepared-text-to-raw-event rewrite, and passes prepared content to parsing and queue selection. (extensions/feishu/src/bot-content.ts:303, 17eca5c27830)
  • Current main still needs the fix: Current main still replaces each mention separately, allowing a short key to consume a longer key and later substitutions to reinterpret inserted display names. The four affected production files also match the pinned PR base. (extensions/feishu/src/bot-content.ts:312, 9c068e13bd18)
  • Released behavior: The latest supplied release, v2026.9.2, also contains the sequential replacement loop; this review does not identify a shipped fix. (extensions/feishu/src/bot-content.ts:312, 3928bad9badf)
  • Entry point and ownership boundary: The account monitor registers the production receive handler and uses the parser to prepare each message. The handler batches only text, retains the original dispatch event content, and carries combined text separately. Parsing still derives bot addressing and forwarding recipients from metadata. The added parameter remains private to this plugin; api.ts does not export these helpers. No Codex runtime or protocol dependency is established. (extensions/feishu/src/monitor.account.ts:307, 17eca5c27830)
  • Sibling behavior and regression coverage: Read the complete parser, content, batching, mention, dedupe-key, and queue-selection owners, plus shared debounce handling. Existing and added tests cover direct/group parsing, adjacent text, literal display names, cross-message key collisions, preserved bot addressing, non-synthesized forwarding intent, stale retries, and original dedupe identity. Rich posts use their separate element renderer and do not enter text batching. (extensions/feishu/src/monitor.reaction.test.ts:788, 17eca5c27830)
  • Direct upstream contract inspection: The PR's SDK-ingress proof claim and extensions/feishu/package.json dependency establish the Lark contract signal. Upstream package metadata verifies repository ownership. Inspected the upstream message event type, which separates content, mention key, identifier, and display name; dispatcher/request-handle.ts preserves message fields while unpacking the event. Sources: event types, dispatcher, and package metadata. These are upstream main sources; the exact installed 1.73.0 package was unavailable locally. (code-gen/events-template.ts:4454)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • m1heng: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (11 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-02T02:06:29.795Z sha e201416 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-02T08:19:06.874Z sha e201416 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-05T05:03:48.378Z sha e201416 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-14T08:45:53.513Z sha e201416 :: needs maintainer review before merge. :: none
  • reviewed August 15, 2026, 8:56 AM ET / 12:56 UTC sha unknown :: needs maintainer review before merge. :: none
  • reviewed 2026-08-22T00:58:26.429Z sha e201416 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T12:36:36.634Z sha e201416 :: needs maintainer review before merge. :: none
  • reviewed September 5, 2026, 4:09 AM ET / 08:09 UTC sha unknown :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Jun 24, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 1, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 30, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 15, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 28, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Sep 5, 2026
@steipete steipete changed the title fix(feishu): replace longer mention keys first fix(feishu): preserve mentions in single and batched messages Sep 5, 2026
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

Head c8b7b58f743955e05645ddfd5a420f50992f305e completes the mention fix: single-pass replacement preserves literal names, and batching carries prepared text without rewriting and normalizing the raw event again. The body records the expanded owner boundary, preserved contributor ancestry, 185 passing tests and SDK/transport proof, and the synthetic-service limitations. Independent Codex review through P2 found no actionable defects.

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Sep 5, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 5, 2026
@steipete
steipete merged commit 6f848b3 into main Sep 5, 2026
160 checks passed
@steipete
steipete deleted the fix/feishu-mention-longest-first branch September 5, 2026 20:50
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
…aw#96311)

* fix(feishu): replace longer mention keys first

* fix(feishu): use copying sort for mention keys

---------

Co-authored-by: Peter Steinberger <[email protected]>
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 maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants