Skip to content

feat(feishu): bot-to-bot conversation support with @mention handling - #89783

Merged
steipete merged 4 commits into
openclaw:mainfrom
heyumeng154-alt:feat/feishu-b2b-conversation
Jul 17, 2026
Merged

steipete merged 4 commits into
openclaw:mainfrom
heyumeng154-alt:feat/feishu-b2b-conversation

Conversation

@GeekyMax

@GeekyMax GeekyMax commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a bounded, default-off Feishu bot-to-bot ingress path.

  • channels.feishu.allowBots: true (or the account-scoped equivalent) opts an account into bot-authored group messages. Omitted/false remains disabled.
  • Bot-authored events are accepted only when the receiving bot is actually mentioned. Same-app mention IDs are checked directly; cross-app-scoped IDs are verified by re-reading the message with the receiving app token.
  • Self-authored, unmentioned, unrelated, or unverifiable bot events fail closed before authorization, loop accounting, and dispatch.
  • Accepted bot turns use the shared channels.defaults.botLoopProtection policy. No Feishu-only loop-control surface is added.
  • Automatic text/chunk/card replies deterministically mention the peer bot with the payload-correct Feishu syntax so delivery does not silently stop. Explicit message_tool sends remain author-controlled.
  • Bot name lookup is bounded by timeout, cache, in-flight deduplication, and a missing-scope circuit breaker.

Required Feishu permissions for this opt-in path are im:message.group_at_msg.include_bot:readonly and im:message:readonly.

Why

Feishu can deliver bot-authored group mentions, but app-scoped bot IDs and payload-specific mention syntax make a naive implementation unsafe and unreliable. The final implementation verifies recipient identity at the Feishu transport boundary, keeps shared loop policy in core, and adds no behavior for existing configurations.

Verification

  • node scripts/run-vitest.mjs extensions/feishu/src/bot.test.ts extensions/feishu/src/bot-name.test.ts extensions/feishu/src/markdown.test.ts extensions/feishu/src/reply-dispatcher.test.ts extensions/feishu/src/bot.stripBotMention.test.ts extensions/feishu/src/config-schema.test.ts extensions/feishu/src/bot.checkBotMentioned.test.ts — 7 files, 274 tests passed.
  • node --import tsx scripts/generate-bundled-channel-config-metadata.ts --check — passed.
  • node --import tsx scripts/generate-config-doc-baseline.ts --check — passed.
  • node scripts/plugin-sdk-surface-report.mjs --check — passed.
  • node scripts/format-docs.mjs --check — 718 files clean.
  • node scripts/generate-docs-map.mjs --check — passed.
  • Hosted changed-surface gate: https://github.com/openclaw/openclaw/actions/runs/29569408352 — passed.
  • Final rebased branch autoreview — clean, zero findings, confidence 0.95.

Real behavior proof

Contributor proof used two bots and one human in a live Feishu group. Bot-to-bot exchanges continued across text, chunked, and card replies; the deterministic reply backstop restored a missing model-authored mention; and disabling bot ingress suppressed replies. Identifiers were redacted. The maintainer rework preserves that ingress/reply capability while making it default-off and adding verified recipient identity plus shared loop protection.

Release note

Feishu accounts can opt into bot-authored group mentions with reliable peer-bot reply mentions and the shared bot-loop guard.

Co-authored-by: Max Huang [email protected]

@openclaw-barnacle openclaw-barnacle Bot added channel: feishu Channel integration: feishu size: XL triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 3, 2026
@clawsweeper

clawsweeper Bot commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 17, 2026, 6:40 AM ET / 10:40 UTC.

Summary
Adds Feishu bot-to-bot group-message handling with payload-aware required mentions, bot identity lookup, shared loop suppression, configuration, documentation, and regression coverage.

PR surface: Source +367, Tests +377, Docs +18, Generated 0. Total +762 across 18 files.

Reproducibility: not applicable. as a strict current-main bug reproduction gate: this PR adds supported Feishu bot-to-bot semantics, and its body supplies a credible live before/after delivery scenario for the underlying failure mode.

Review metrics: 1 noteworthy metric.

  • Config and defaults: 1 option added, 1 ingress default changed. allowBots adds an operator setting while making previously reachable bot-authored events opt-in, which is upgrade-sensitive before merge.

Stored data model
Persistent data-model change detected: persistent cache schema: extensions/feishu/src/bot-name.ts, unknown-data-model-change: src/config/bundled-channel-config-metadata.generated.ts. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] Existing Feishu installations that already receive bot-authored events may stop responding after upgrade until an operator explicitly enables channels.feishu.allowBots.
  • [P1] Bot-authored automatic replies intentionally stop using streaming cards so every emitted unit can notify the peer bot; maintainers must accept that rendering change as the delivery-safety tradeoff.
  • [P1] The PR body still contains language suggesting bot admission defaults to accept, while the proposed docs and effective gate describe an opt-in default, so the upgrade contract should be stated consistently before merge.

Maintainer options:

  1. Document and accept the transition (recommended)
    Keep the opt-in default, make the upgrade impact consistent across the PR context and docs, and merge after exact-head checks complete.
  2. Preserve existing ingress by default
    Change the default to admit bot-authored events while retaining an explicit disable option, then re-prove both fresh and upgraded installations.
  3. Pause the combined feature
    Split or close the PR if maintainers do not want to own Feishu bot-to-bot admission and reply-delivery semantics.

Next step before merge

  • [P2] After exact-head checks finish, the assigned feature owner should explicitly accept or revise the default-off ingress and non-streaming delivery transition before merge.

Maintainer decision needed

  • Question: Should Feishu bot-authored group messages become an explicit opt-in that disables previously reachable bot ingress by default and uses non-streaming, payload-correct replies when enabled?
  • Rationale: The implementation is coherent and proven, but the default admission and rendering transition can change existing installations and therefore needs intentional product ownership rather than an automated merge judgment.
  • Likely owner: steipete — steipete is assigned and authored the current implementation and refinement commits, making them the clearest available owner for this product and compatibility choice.
  • Options:
    • Accept the opt-in transition (recommended): Keep allowBots disabled by default, align all upgrade wording, and intentionally accept non-streaming replies for enabled bot-to-bot turns.
    • Preserve prior admission: Default bot-authored ingress to its previously reachable behavior while retaining false as an explicit restriction, then re-prove fresh-install and upgrade behavior.
    • Narrow or pause the feature: Split out only reusable mention or loop-safety work if maintainers do not want supported Feishu bot-to-bot conversation semantics.

Security
Cleared: The patch adds no dependency, workflow, publishing, secret-access, or downloaded-code surface; its external bot-name request is bounded by timeout, caching, backoff, and identity verification.

Review details

Best possible solution:

Keep the feature plugin-local, explicitly document the default-off upgrade transition in the PR context and Feishu docs, and retain the payload-correct required mentions, shared loop guard, identity checks, and non-streaming fallback for bot-authored turns.

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

Not applicable as a strict current-main bug reproduction gate: this PR adds supported Feishu bot-to-bot semantics, and its body supplies a credible live before/after delivery scenario for the underlying failure mode.

Is this the best way to solve the issue?

Yes for the implementation shape: Feishu-owned ingress, shared loop protection, verified bot identity, and payload-specific per-unit mentions are the narrow maintainable solution; the unresolved question is the intentional default and upgrade policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 9769642e7f60.

Label changes

Label justifications:

  • P1: The PR controls Feishu bot-to-bot admission and required mentions, where a wrong policy or payload path can silently stop active conversations.
  • merge-risk: 🚨 compatibility: Upgraded installations receiving bot-authored Feishu events may stop responding unless operators add the new allowBots setting.
  • merge-risk: 🚨 message-delivery: The changed admission, mention, chunking, and card behavior directly determines whether the peer bot receives each reply.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • feature: ✨ showcase: ClawSweeper spotlight: unusually compelling feature idea for maintainer attention. Reliable, loop-bounded bot-to-bot collaboration across Feishu text and card delivery unlocks a distinctive multi-agent group workflow.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides redacted live Feishu output showing peer-bot delivery for text and card paths, deterministic mention backfill, continued conversation, and allowBots suppression after the change.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides redacted live Feishu output showing peer-bot delivery for text and card paths, deterministic mention backfill, continued conversation, and allowBots suppression after the change.
Evidence reviewed

PR surface:

Source +367, Tests +377, Docs +18, Generated 0. Total +762 across 18 files.

View PR surface stats
Area Files Added Removed Net
Source 7 400 33 +367
Tests 6 377 0 +377
Docs 3 20 2 +18
Config 0 0 0 0
Generated 2 18 18 0
Other 0 0 0 0
Total 18 815 53 +762

What I checked:

  • Current-main behavior: Current main does not classify Feishu message senders as bots or apply an allowBots gate, bot-name resolution, shared bot-pair loop recording, or required outbound peer-bot mentions. (github.com) (extensions/feishu/src/bot.ts:318, 9769642e7f60)
  • Ingress and default transition: The proposed configuration adds a boolean allowBots; the accompanying Feishu documentation describes bot-authored events as ignored by default and requires operators to enable the option. (extensions/feishu/src/config-schema.ts:223, a31970ac65e9)
  • Delivery invariant: The proposed dispatcher carries required peer-bot mentions across outbound chunks and disables streaming cards for those turns because that path cannot attach the required native mention recipient. (extensions/feishu/src/reply-dispatcher.ts:147, a31970ac65e9)
  • Regression coverage: The branch adds or expands coverage for sender classification, admission policy, identity verification, loop suppression, per-chunk mention budgeting, payload-specific mentions, and bot-name resolver failure state. (extensions/feishu/src/bot.test.ts:2028, a31970ac65e9)
  • Real behavior proof: The PR body records a redacted live Feishu group run where text and card replies reached the peer bot, the deterministic backstop repaired an omitted mention, and disabling allowBots suppressed bot-authored turns. (a31970ac65e9)
  • Scoped repository policy: The implementation remains within the Feishu plugin and uses documented Plugin SDK imports, consistent with the extension ownership boundary. (raw.githubusercontent.com) (extensions/AGENTS.md:1, 9769642e7f60)

Likely related people:

  • steipete: Assigned the PR and authored all four current-head commits covering the Feishu runtime implementation, resolver-state tests, mention identity verification, and generated docs map. (role: recent feature owner; confidence: high; commits: ccea8570806f, f932d48adf8f, 78f5c87e7647; files: extensions/feishu/src/bot.ts, extensions/feishu/src/bot-name.ts, extensions/feishu/src/reply-dispatcher.ts)
  • vincentkoc: Recent main history ties vincentkoc to Feishu streaming-card closeout, final-delivery coalescing, start backoff, runtime seams, and mention-type work. (github.com) (role: recent delivery-path contributor; confidence: medium; commits: 84a22a6, 455eba7, 4df0e10; files: extensions/feishu/src/reply-dispatcher.ts)
  • Takhoffman: Main history repeatedly associates Takhoffman with Feishu structured-card, streaming, reply-drop, deduplication, and topic-delivery changes adjacent to this PR's risk surface. (github.com) (role: historical Feishu reviewer and merger; confidence: medium; commits: df3a247, 9e8df16, 024af2b; files: extensions/feishu/src/reply-dispatcher.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (6 earlier review cycles)
  • reviewed 2026-06-25T15:23:51.420Z sha 120a6a97767897bd6d233af02c246ccd9e1a1b07 :: found issues before merge. :: [P3] Keep missing bot scope out of the breaker
  • reviewed 2026-07-17T03:32:22.457Z sha 165f0bf6327d77f1db2015a0e9ad9a7b81877645 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-17T07:56:51.741Z sha 8998573a9d8e131c8038a2994c0f9a0cd05736aa :: needs maintainer review before merge. :: none
  • reviewed 2026-07-17T09:05:17.957Z sha b87f5e0fb95fb2c04e869018346c75ad1c77de59 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-17T09:48:27.980Z sha b87f5e0fb95fb2c04e869018346c75ad1c77de59 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-17T10:13:40.952Z sha d1e28af87eeb537e6afee12f729fde003ff477c1 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 3, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label Jun 3, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jun 3, 2026
@GeekyMax
GeekyMax force-pushed the feat/feishu-b2b-conversation branch from ce11c92 to 817d87c Compare June 3, 2026 10:17
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. labels Jun 3, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 3, 2026
@GeekyMax
GeekyMax force-pushed the feat/feishu-b2b-conversation branch 3 times, most recently from 54ae4e1 to 679b90f Compare June 4, 2026 07:11
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Jun 4, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Jun 4, 2026
@GeekyMax
GeekyMax force-pushed the feat/feishu-b2b-conversation branch from 679b90f to 73b42e2 Compare June 4, 2026 07:40
@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 4, 2026
@GeekyMax

GeekyMax commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The previous review came back as off-meta tidepool / "review did not complete", so this is a re-review request. The branch was rebased onto current main and CI now runs the full suite (the only red check, checks-fast-contracts-plugins-a, is a pre-existing packages/plugin-sdk/src/testing.ts guardrail drift on main, unrelated to this PR — it fails on other PRs too).

Since the prior reviews, the two P1 findings were addressed:

  • Card/streaming mentions now use the lark_md <at id=...> syntax (text/post still use <at user_id="...">), applied per outbound chunk and on streaming-card close — verified live (a card reply reached the peer bot).
  • Bot-authored ingress is gated by a new allowBots opt-in and wired into core botLoopProtection (sliding window, default on) plus the Layer-1 self-filter — allowBots: false verified live (peer bot messages no longer trigger a reply).

@clawsweeper

clawsweeper Bot commented Jun 4, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 4, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 4, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 4, 2026
@GeekyMax
GeekyMax force-pushed the feat/feishu-b2b-conversation branch from 0a2cc41 to a3d4f97 Compare June 5, 2026 03:47
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 5, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 5, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jun 14, 2026
@GeekyMax
GeekyMax force-pushed the feat/feishu-b2b-conversation branch from a3d4f97 to d533e2e Compare June 15, 2026 07:56
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 15, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jun 15, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@steipete

Copy link
Copy Markdown
Contributor

Maintainer rework complete. READY FOR /prepare-pr.

Final shape:

  • one default-off Feishu allowBots gate;
  • verified recipient mention identity, including cross-app-scoped IDs;
  • shared channels.defaults.botLoopProtection, with no Feishu-only loop policy;
  • payload-correct peer-bot mentions on automatic text, chunked, and card replies;
  • fail-closed handling for self, unmentioned, unrelated, and unverifiable bot events;
  • generated config metadata and docs map refreshed.

Proof:

Contributor credit remains with @GeekyMax; release-note context and the exact co-author trailer are in the PR body.

@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

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 feature: ✨ showcase ClawSweeper spotlight: unusually compelling feature idea for maintainer attention. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: L stale Marked as stale due to inactivity status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants