← Back to PRs

#9253: Fix: Feishu chat ID mismatch causing session context confusion

by vishaltandale00 open 2026-02-05 01:57 View on GitHub →
stale
## Summary Fixes #9246 - Feishu chat ID mismatch causing session context confusion across different groups. ## Root Cause The `/whoami` command was incorrectly displaying `ctx.From` (sender's open_id) instead of `ctx.To` (chat_id) for group chats. This caused the agent to report wrong group IDs when asked, leading to session context confusion where messages from one group would reference context from another group. ## The Bug In `src/auto-reply/reply/commands-info.ts` line 194-196: ```typescript if (params.ctx.ChatType === "group" && params.ctx.From) { lines.push(`Chat: ${params.ctx.From}`); // ❌ Wrong - shows sender ID } ``` ## The Fix ```typescript if (params.ctx.ChatType === "group" && params.ctx.To) { lines.push(`Chat: ${params.ctx.To}`); // ✅ Correct - shows chat ID } ``` ## Impact ✅ Fixes session context confusion in Feishu groups ✅ Agent now correctly identifies which group it's in ✅ `/whoami` command displays correct chat_id (oc_xxx) instead of sender's open_id (ou_xxx) ✅ Prevents cross-group context bleeding ## Testing Manual testing recommended: 1. Create multiple Feishu groups with the bot 2. Send messages to each group 3. Verify `/whoami` shows correct chat_id for each group 4. Verify agent responses don't reference context from other groups ## Changed Files - `src/auto-reply/reply/commands-info.ts` (2 lines changed) <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR updates the `/whoami` output for Feishu group chats to display the chat identifier from `ctx.To` (chat_id) instead of `ctx.From` (sender open_id). This aligns the identity report with how session routing/state tracking elsewhere treats `ctx.To` as the conversation target, and prevents operators from copying the wrong ID when diagnosing or scoping group sessions. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk. - Change is isolated to `/whoami` display formatting and matches existing session routing conventions that prioritize `ctx.To` for conversation targeting; no behavioral side-effects beyond corrected diagnostics output were found. - No files require special attention <!-- greptile_other_comments_section --> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs