#9662: fix(feishu): include sender ID in direct messages for auth
channel: feishu
stale
Cluster:
Feishu Enhancements and Fixes
## Summary
Add `ForceIncludeSenderMeta` flag to `MsgContext` that allows channels to force sender metadata injection even for direct/DM chats. Feishu now sets this flag so AI can access the sender's `open_id` for identity verification in both group and direct messages.
Also improved `senderName` resolution to use `open_id` as fallback when `user_id` is unavailable (common due to Feishu permission requirements).
## Problem
Feishu direct messages were not passing `SenderId` (open_id) to AI, while group messages were injecting `[from: unknown (ou_xxx)]`. This made it impossible for AI to perform identity verification in DM conversations.
## Changes
- `src/auto-reply/templating.ts` - Added `ForceIncludeSenderMeta` field to MsgContext
- `src/auto-reply/reply/inbound-sender-meta.ts` - Check the new flag to allow sender meta injection for direct chats
- `src/feishu/message.ts` - Set the flag and improved senderName fallback
- `src/auto-reply/inbound.test.ts` - Added test cases
## Test plan
- [x] Unit tests pass
- [x] Type check passes
- [ ] Manual test with Feishu DM
🤖 Generated with [Claude Code](https://claude.ai/code)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR adds a `ForceIncludeSenderMeta` boolean to `MsgContext` and updates the shared inbound-body formatting to allow appending a `[from: ...]` line even in DMs when that flag is set. Feishu’s inbound message handler now always sets this flag and adjusts sender labeling so the AI can see the sender’s `open_id` in direct messages for identity verification. Tests were extended to cover forced sender-meta injection for `direct`/`dm` chat types.
<h3>Confidence Score: 3/5</h3>
- This PR is likely safe to merge, but it changes DM formatting semantics and Feishu sender labeling in a way that should be confirmed.
- Core change is small and covered by unit tests, but (1) Feishu now uses IDs as `SenderName` fallback, which will surface in user-visible/meta text, and (2) the new force flag intentionally bypasses the DM guard in shared logic, which can affect other channels if misused.
- src/feishu/message.ts, src/auto-reply/reply/inbound-sender-meta.ts
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#13211: feat(feishu): skip reply-to in DM conversations
by Vincentwei1021 · 2026-02-10
76.9%
#10309: fix: use group ID for peer.id in Feishu group messages
by ParsifalC · 2026-02-06
74.3%
#19793: feat(feishu): reply-in-thread, parallel group sessions, and fire-an...
by yinsn · 2026-02-18
73.4%
#18529: feat(feishu): add parentId and rootId to inbound context for quote/...
by qiangu · 2026-02-16
73.3%
#13761: fix(feishu): silently degrade when contact permission is missing
by echoVic · 2026-02-11
73.1%
#22054: fix(auto-reply): Hide message_id and sender metadata in direct chats
by jd316 · 2026-02-20
72.6%
#9756: fix(feishu): prevent message redelivery during long AI generation
by cszhouwei · 2026-02-05
72.0%
#10513: feat(feishu): add quota optimization flags
by BigUncle · 2026-02-06
71.8%
#7261: fix(telegram): preserve DM topic thread id for outbound media
by ViffyGwaanl · 2026-02-02
70.9%
#19027: fix(feishu): keep chunked messages in topic/thread context
by qiangu · 2026-02-17
70.3%