Skip to content

fix(feishu): allow card-action callbacks to bypass requireMention in groups (#85450) - #85609

Closed
zhouhe-xydt wants to merge 2 commits into
openclaw:mainfrom
zhouhe-xydt:fix/85450-card-action-requireMention
Closed

zhouhe-xydt wants to merge 2 commits into
openclaw:mainfrom
zhouhe-xydt:fix/85450-card-action-requireMention

Conversation

@zhouhe-xydt

Copy link
Copy Markdown
Contributor

Summary

Fixes structured card action callbacks (e.g., `execute_confirmed`) being silently dropped in Feishu group chats with `requireMention: true`.

Problem

When a user clicks a button on a bot-sent interactive card in a group chat with `requireMention: true`, the card action handler builds a synthetic message and dispatches it via `handleFeishuMessage`. Because the synthetic message has no `mentions` array, `checkBotMentioned` returns `false`, and `resolveFeishuGroupSenderActivationIngressAccess` drops the message with:
```
message in group {chatId} did not mention bot
```

This is incorrect because clicking a button on a bot-sent card is already direct engagement with the bot — the user should not need to @mention the bot separately.

Changes

  • `extensions/feishu/src/bot.ts`: In `handleFeishuMessage`, detect synthetic card-action messages (`message_id` starts with `card-action-`) and set `requireMention = false` before the group sender activation ingress check.
  • `extensions/feishu/src/bot.broadcast.test.ts`: Added regression test verifying card-action synthetic messages dispatch successfully even when `requireMention=true`.

Verification

Behavior addressed: Prevent card action callbacks from being dropped in requireMention groups
Real environment tested: Local source checkout, Ubuntu Linux, Node 22
Exact steps or command run after this patch:

  • pnpm test extensions/feishu/src/bot.broadcast.test.ts
  • pnpm format:check extensions/feishu/src/bot.ts extensions/feishu/src/bot.broadcast.test.ts
    Evidence after fix: 7 tests pass, 0 failures; formatting check passes
    Observed result after fix: Card-action synthetic messages bypass requireMention and are dispatched normally
    What was not tested: Live Feishu webhook with actual card button click in a group chat

Fixes #85450

…ingSignatures

Add latestAssistantIndex guard to stripInvalidThinkingSignatures so it
skips the most recent assistant turn, matching the existing behavior in
dropThinkingBlocks. Anthropic requires thinking blocks in the latest
assistant message to be sent back verbatim; modifying them causes
invalid_request_error.

Fixes openclaw#85557
…groups

Structured card action callbacks (e.g., execute_confirmed) were silently
dropped in group chats with requireMention=true because the synthetic
message built from the card action has no mentions array. Since clicking
a button on a bot-sent card is already direct bot engagement, the
requireMention check should not apply.

Fixes openclaw#85450
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling channel: feishu Channel integration: feishu triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. size: S labels May 23, 2026
@clawsweeper

clawsweeper Bot commented May 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Latest ClawSweeper review: 2026-05-23 03:56 UTC / May 22, 2026, 11:56 PM ET.

Workflow note: Future ClawSweeper reviews update this same comment in place.

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.

Summary
The branch makes Feishu synthetic card-action messages bypass requireMention, adds a Feishu broadcast regression test, and also changes pi-embedded-runner thinking-signature cleanup and tests.

Reproducibility: yes. from source inspection: card-action synthetic events are dispatched through handleFeishuMessage without mentions, and current group requireMention gating drops unmentioned group messages. The linked issue also includes matching Feishu logs.

PR rating
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦪 silver shellfish
Summary: The Feishu bug signal is useful, but mock-only proof plus mixed unrelated runtime changes and a brittle bypass contract make the PR not quality-ready.

Rank-up moves:

  • Remove or split the src/agents/pi-embedded-runner/* changes into a separate PR.
  • Use an internal card-action marker or handler option instead of the message_id prefix as the bypass contract.
  • Add redacted live Feishu group card-button proof; screenshots, terminal output, logs, or a recording are fine if private details are redacted.
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.

Real behavior proof
Needs real behavior proof before merge: The PR body reports unit test and format output only and says no live Feishu webhook/card click was tested, so redacted real behavior proof is still required before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • The Feishu bypass is keyed to message_id.startsWith("card-action-") inside a handler that also processes normal webhook messages, so it can weaken requireMention if a non-card message reaches that path with the same prefix.
  • The branch also ships an unrelated pi-embedded-runner thinking/session behavior change for another issue, which would alter transcript replay behavior under a Feishu PR.
  • The contributor has not shown a live Feishu group card-click after the patch; the submitted proof is unit tests and formatting only.

Maintainer options:

  1. Split and harden before merge (recommended)
    Remove the unrelated thinking/session changes, switch the Feishu bypass to an internal synthetic card-action marker, and require redacted live Feishu proof before landing.
  2. Maintainer-owned combined merge
    A maintainer could intentionally review and own both unrelated fixes together, but that should include explicit approval for the session replay change and live Feishu proof.
  3. Close for separate narrow PRs
    If the branch is not split, close it and ask for separate Feishu and thinking PRs so each surface can be reviewed and proved independently.

Next step before merge
Needs contributor or maintainer handling: split the unrelated thinking changes, confirm the internal card-action marker approach, and require real Feishu proof that automation cannot supply.

Security
Needs attention: The diff has no dependency or supply-chain changes, but the Feishu activation bypass is currently tied to an externally sourced message-id prefix.

Review findings

  • [P2] Gate the bypass on an internal card-action marker — extensions/feishu/src/bot.ts:663-665
  • [P2] Split out the unrelated thinking change — src/agents/pi-embedded-runner/thinking.ts:111-119
Review details

Best possible solution:

Land a narrow Feishu-only fix that uses an internal card-action signal, preserves normal requireMention for ordinary messages, includes focused regression coverage, and has redacted live Feishu group card-click proof; move the thinking fix to its own PR.

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

Yes from source inspection: card-action synthetic events are dispatched through handleFeishuMessage without mentions, and current group requireMention gating drops unmentioned group messages. The linked issue also includes matching Feishu logs.

Is this the best way to solve the issue?

No as-is. The Feishu fix direction is plausible, but the patch should use an internal synthetic card-action marker and should not bundle unrelated thinking/session changes.

Label changes:

  • add P1: The linked Feishu bug drops card-action callbacks in requireMention group chats, which is a broken channel workflow affecting real users.
  • add merge-risk: 🚨 message-delivery: The patch changes when Feishu group messages bypass mention-gated dispatch, so an incorrect gate could deliver messages the bot should ignore.
  • add merge-risk: 🚨 session-state: The branch also changes agent thinking-signature replay behavior outside the Feishu fix, which can affect transcript/session state.
  • add rating: 🧂 unranked krab: Current PR rating is 🧂 unranked krab because proof is 🧂 unranked krab, patch quality is 🦪 silver shellfish, and The Feishu bug signal is useful, but mock-only proof plus mixed unrelated runtime changes and a brittle bypass contract make the PR not quality-ready.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports unit test and format output only and says no live Feishu webhook/card click was tested, so redacted real behavior proof is still required before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P1: The linked Feishu bug drops card-action callbacks in requireMention group chats, which is a broken channel workflow affecting real users.
  • merge-risk: 🚨 message-delivery: The patch changes when Feishu group messages bypass mention-gated dispatch, so an incorrect gate could deliver messages the bot should ignore.
  • merge-risk: 🚨 session-state: The branch also changes agent thinking-signature replay behavior outside the Feishu fix, which can affect transcript/session state.
  • rating: 🧂 unranked krab: Current PR rating is 🧂 unranked krab because proof is 🧂 unranked krab, patch quality is 🦪 silver shellfish, and The Feishu bug signal is useful, but mock-only proof plus mixed unrelated runtime changes and a brittle bypass contract make the PR not quality-ready.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports unit test and format output only and says no live Feishu webhook/card click was tested, so redacted real behavior proof is still required before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Full review comments:

  • [P2] Gate the bypass on an internal card-action marker — extensions/feishu/src/bot.ts:663-665
    The new bypass trusts event.message.message_id.startsWith("card-action-"), but normal Feishu webhook messages also reach handleFeishuMessage after only shape validation of message_id. Use a marker or handler option set only by the card-action dispatcher so ordinary group messages stay behind requireMention.
    Confidence: 0.78
  • [P2] Split out the unrelated thinking change — src/agents/pi-embedded-runner/thinking.ts:111-119
    This PR is scoped and verified as a Feishu card-action fix, but it also changes pi-embedded-runner thinking-signature replay behavior for a separate issue. Move that runtime/session change to its own PR or remove it from this branch before merging the Feishu fix.
    Confidence: 0.93

Overall correctness: patch is incorrect
Overall confidence: 0.86

Security concerns:

  • [low] Activation bypass uses message_id prefix — extensions/feishu/src/bot.ts:663
    Because normal Feishu ingress accepts message_id from the webhook payload, using a prefix in that field as the bypass contract can weaken the group requireMention gate outside the synthetic card-action path.
    Confidence: 0.72

Acceptance criteria:

  • node scripts/run-vitest.mjs extensions/feishu/src/bot.broadcast.test.ts
  • focused live Feishu group card-action click proof with private details redacted

What I checked:

Likely related people:

  • Peter Steinberger: Available blame/log history shows the current Feishu card-action, group mention gate, and pi-embedded-runner thinking helper landed in commit faad2b0. (role: current area contributor in available history; confidence: medium; commits: faad2b0a7160; files: extensions/feishu/src/bot.ts, extensions/feishu/src/card-action.ts, src/agents/pi-embedded-runner/thinking.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against bb5abefcf58a.

@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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels May 23, 2026
@clawsweeper

clawsweeper Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

@BingqingLyu

This comment was marked as spam.

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

Labels

agents Agent runtime and tooling channel: feishu Channel integration: feishu merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Structured card action callback filtered by requireMention in group chats

2 participants