Skip to content

fix(feishu): route topic messages to thread ids - #9986

Closed
LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:fix/feishu-topic-thread-routing
Closed

fix(feishu): route topic messages to thread ids#9986
LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:fix/feishu-topic-thread-routing

Conversation

@LeonSGP43

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes Feishu topic-thread routing for P2P chats.

When a user sends a message from a Feishu topic thread inside a P2P chat, Hermes was creating a new outbound message with receive_id_type="chat_id" even when thread_id was present in metadata. That caused replies to appear in the main chat instead of the topic.

This change keeps the existing reply flow intact, but makes non-reply sends target thread_id whenever thread metadata is present.

Related Issue

Fixes #9916

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Route Feishu non-reply outbound messages to thread_id instead of chat_id when metadata["thread_id"] is present in gateway/platforms/feishu.py
  • Preserve existing reply_to behavior and reply_in_thread handling for true reply sends
  • Add a regression test that verifies new outbound topic messages use receive_id_type="thread_id" in tests/gateway/test_feishu.py

How to Test

  1. Run source .venv/bin/activate && python -m pytest tests/gateway/test_feishu.py -q
  2. Confirm the suite passes, including test_send_routes_new_message_to_thread_when_thread_metadata_present
  3. In a Feishu P2P chat topic, send a message from inside the topic and confirm the bot reply lands in that topic rather than the main chat

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: macOS 15.x

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

  • Targeted verification: tests/gateway/test_feishu.py -q107 passed
  • I left the full-suite checkbox unchecked because local pytest tests/ -q currently has unrelated pre-existing failures on main

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: Bot replies leak out of P2P topic thread into main chat

1 participant