fix(feishu): prevent topic replies from spawning new threads#19711
Merged
Conversation
…l patch) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced May 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Salvage of #16620 by @julysir onto current main.
Summary
When replying inside a Feishu topic-enabled group chat, the agent created a new topic/thread instead of staying in the current one. The reply anchor was hard-set to the CURRENT message_id rather than the incoming reply's parent. On Feishu, with a thread_id present AND a reply_to_message_id available, use reply_to_message_id as the anchor so the agent's reply lands inside the existing thread. Also extend
_process_inbound_messageto fall back toroot_idwhen computing thread_id / reply_to_message_id so Feishu's Topic Mode API shape is handled.Conflict resolution during salvage
Main has since added ephemeral-message handling (
_unwrap_ephemeral,_schedule_ephemeral_delete) at the two dispatch call sites this PR targets. Re-applied the Feishu reply-anchor fix in-place on the HEAD send calls (patchingreply_to=inside the existing_r = await self._send_with_retry(...)blocks) rather than re-introducing the PR's parallel send block which would now double-send the response.Changes
root_idfor thread_id / reply_to_message_id in_process_inbound_messageValidation
scripts/run_tests.sh tests/gateway/ -k feishu -> 377 passed
Original PR: #16620