#10309: fix: use group ID for peer.id in Feishu group messages
channel: feishu
stale
size: XS
Cluster:
Feishu Messaging Fixes
Fixes #10207
**[AI-assisted]** This PR was developed with AI assistance using OpenClaw's main agent with Claude Sonnet 4.5.
## Problem
Feishu group messages were incorrectly using the sender's user ID (ou_*) as the peer.id in session keys instead of the group chat ID (oc_*).
## Root Cause
In `extensions/feishu/src/bot.ts`, the `feishuFrom` variable was always set to `feishu:${senderOpenId}`, regardless of whether the message was from a group or DM.
This caused binding matching to fail because:
- **Binding expected**: `peer.id = "oc_42b416c54d94c23adf3213cd339454ff"` (group ID)
- **Actual**: `peer.id = "ou_078b67a333caf3b10b5910fe69295"` (user ID)
- No binding matched, so it fell back to the default agent
## Solution
Modified the `feishuFrom` logic in `handleFeishuMessage()`:
- **Group messages**: `From: feishu:group:${chatId}`
- **DM messages**: `From: feishu:${senderOpenId}`
This ensures that the peer.id in session keys matches binding expectations.
## Testing
**[Lightly tested]**
- Reviewed code changes and logic
- Verified that `peer.id` now matches binding expectations
- Code follows existing patterns in `outbound-session.ts`
- Session key format aligns with other channel extensions (e.g., Teams uses group ID for From)
## Session Log for Validation
Current session key: `agent:main:feishu:group:ou_078b67a333caf3b10b5910fe69295`
**Before fix:**
- Peer ID used sender ID: `ou_078b67a333caf3b10b5910fe69295`
- This did not match binding expectation: `oc_42b416c54d94c23adf3213cd339454ff`
- Result: Fell back to default agent
**After fix (expected):**
- Peer ID should use group ID: `oc_42b416c54d94c23adf3213cd339454ff`
- This will match binding expectation
- Result: Proper multi-agent routing
## What This Code Does
The fix modifies the `feishuFrom` variable assignment to conditionally use:
1. **Group messages**: The group chat ID (oc_*) as the peer identifier
2. **DM messages**: The sender's user ID (ou_*) as the peer identifier
This aligns the inbound message routing with the binding system's expectations, allowing multi-agent setups to properly route Feishu group messages based on configured bindings.
## Impact
- Enables proper multi-agent routing for Feishu groups as configured in bindings
- Fixes session key generation to match binding peer.id expectations
- No breaking changes to existing functionality
---
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
- Fixes Feishu group routing by changing inbound `From` for group messages to use group chat ID (`feishu:group:${chatId}`) instead of sender open_id.
- Keeps DM `From` unchanged (`feishu:${senderOpenId}`) so per-user direct sessions still work.
- Aligns with `From`/session key identity with `peer.id`/bindings expectations for group chats, enabling correct multi-agent binding matches.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- The change is narrowly scoped to Feishu inbound identity formatting for group messages, aligns with how other channel extensions (e.g., Teams) encode group/channel `From`, and does not affect message parsing, allowlisting, or dispatch flow beyond improving routing/binding matching.
- extensions/feishu/src/bot.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#9253: Fix: Feishu chat ID mismatch causing session context confusion
by vishaltandale00 · 2026-02-05
85.7%
#10407: fix(feishu): Remove incorrect oc_ prefix assumption in resolveFeish...
by Bermudarat · 2026-02-06
83.2%
#21955: fix(line): remove redundant group:/room: prefix from buildPeerId (#...
by lailoo · 2026-02-20
82.0%
#19793: feat(feishu): reply-in-thread, parallel group sessions, and fire-an...
by yinsn · 2026-02-18
80.6%
#21484: fix(feishu): scope message deduplication by accountId to support mu...
by guanyu-zhang · 2026-02-20
80.1%
#13211: feat(feishu): skip reply-to in DM conversations
by Vincentwei1021 · 2026-02-10
79.8%
#13761: fix(feishu): silently degrade when contact permission is missing
by echoVic · 2026-02-11
78.1%
#19027: fix(feishu): keep chunked messages in topic/thread context
by qiangu · 2026-02-17
76.8%
#19254: fix(feishu): honor wildcard group config for reply policy
by WaynePika · 2026-02-17
76.6%
#13970: feat: add Feishu topic auto-threading for message tool
by 4ier · 2026-02-11
76.2%