Skip to content

fix(feishu): reply in same topic instead of creating new one in topic-mode groups - #9760

Closed
zhing2006 wants to merge 1 commit into
NousResearch:mainfrom
zhing2006:fix/feishu-topic-reply-in-thread
Closed

fix(feishu): reply in same topic instead of creating new one in topic-mode groups#9760
zhing2006 wants to merge 1 commit into
NousResearch:mainfrom
zhing2006:fix/feishu-topic-reply-in-thread

Conversation

@zhing2006

@zhing2006 zhing2006 commented Apr 14, 2026

Copy link
Copy Markdown

What does this PR do?

Fixes Feishu bot replies creating a new topic instead of replying within the existing topic in topic-mode groups (话题模式群).

Root cause: progress messages and streaming responses were sent via the Feishu create API (no reply_to parameter), which cannot target a specific topic. Only the reply API with reply_in_thread=true can send messages into an existing topic. Since reply_to was missing, the code fell through to the create branch in _send_raw_message(), causing every bot response to appear as a new topic.

Related Issue

Fixes #6969

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • gateway/stream_consumer.py: Add optional reply_to parameter to GatewayStreamConsumer.__init__() and use it in _send_or_edit() when sending the first message chunk
  • gateway/run.py: Pass reply_to=event_message_id in all 3 progress-message adapter.send() calls inside send_progress_messages(), and in the GatewayStreamConsumer constructor
  • gateway/platforms/feishu.py: Add defensive root_id fallback for thread_id in _process_inbound_message() for forum-type chats (topic-mode groups where thread_id may be absent); add debug logging for thread context

How to Test

  1. Create or use a Feishu group with topic mode enabled (话题模式)
  2. Open an existing topic and @mention the bot
  3. Verify the bot's reply appears inside the same topic, not as a new topic
  4. Also verify normal (non-topic) group and DM replies still work correctly

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: Windows 11 Pro

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

Before fix — _send_raw_message log showing reply_to=None:

[Feishu] _send_raw_message: reply_to=None reply_in_thread=True msg_type=text metadata={'thread_id': 'omt_1abbed20d40f1c9e'}

After fix — bot reply correctly appears within the same Feishu topic.

…-mode groups

Progress messages and streaming responses were sent via the `create`
API (no `reply_to`) instead of the `reply` API. Feishu's `create` API
cannot target a specific topic, so messages in topic-mode groups always
created a new topic.

- Add `reply_to` parameter to `GatewayStreamConsumer` so the first
  streamed chunk uses the reply API with `reply_in_thread=true`
- Pass `event_message_id` as `reply_to` in all three progress-message
  send paths in `send_progress_messages()`
- Add defensive `root_id` fallback for `thread_id` in forum-type chats

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@zhing2006 zhing2006 closed this Apr 14, 2026
@zhing2006 zhing2006 reopened this Apr 14, 2026
@zhing2006

Copy link
Copy Markdown
Author

Hey, just wanted to check in, this fixes an issue I ran into where the bot keeps opening new topics in Feishu topic-mode groups instead of replying in the same thread. Tested it on my end and it's working. Would appreciate it if someone could approve the CI run when they get a moment. Let me know if anything needs changing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feishu topic progress messages create new topics instead of staying in the original topic

1 participant