← Back to PRs

#10309: fix: use group ID for peer.id in Feishu group messages

by ParsifalC open 2026-02-06 09:47 View on GitHub →
channel: feishu stale size: XS
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