Skip to content

fix(feishu): preserve topic thread context for forum replies#8656

Open
sgaofen wants to merge 1 commit into
NousResearch:mainfrom
sgaofen:codex/feishu-topic-thread-context
Open

fix(feishu): preserve topic thread context for forum replies#8656
sgaofen wants to merge 1 commit into
NousResearch:mainfrom
sgaofen:codex/feishu-topic-thread-context

Conversation

@sgaofen

@sgaofen sgaofen commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • preserve Feishu forum/topic thread context when inbound messages omit thread_id
  • derive thread context from upper_message_id first, then parent_id, but only for forum chats
  • add regression tests to lock in forum thread inference and prove regular group replies are not misclassified as threads

Problem

Part of #7734 reports that messages sent inside an existing Feishu topic can still trigger Hermes replies that start a new topic instead of staying inside the current one.

The adapter only propagated message.thread_id into source.thread_id. In Feishu forum chats, that field is not reliably present on every inbound message, so the downstream gateway lost the thread context and sent follow-up replies without reply_in_thread=True.

Fix

  • add _resolve_inbound_thread_id() in gateway/platforms/feishu.py
  • keep explicit thread_id when Feishu provides it
  • for forum chats only, fall back to upper_message_id, then parent_id
  • leave regular group messages unchanged so ordinary replies do not become synthetic threads

Scope

This PR addresses the topic-threading half of #7734. The interactive authorization-card button error discussed in that issue appears to depend on Feishu callback permissions / account capabilities and is intentionally out of scope here.

Testing

  • python3 -m py_compile gateway/platforms/feishu.py tests/gateway/test_feishu.py
  • uv run --extra dev pytest -o addopts='' tests/gateway/test_feishu.py -k 'thread_context or replies_in_thread_when_thread_metadata_present or fetches_reply_to_text'

Notes

  • uv run --extra dev pytest -o addopts='' tests/gateway/test_feishu.py -q still hits one pre-existing mock-builder failure on current main (test_build_event_handler_registers_reaction_and_card_processors) unrelated to this change.

Platform Tested

  • macOS 15.x (Apple Silicon)

Contribution Guide Notes

  • Reviewed CONTRIBUTING.md and checked for existing open PRs before submitting this scoped change.
  • Ran the targeted verification commands listed above for this PR. I have not claimed a full repo-wide pytest tests/ -q pass unless explicitly noted.

@sgaofen sgaofen marked this pull request as ready for review April 13, 2026 00:53
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/feishu Feishu / Lark adapter labels Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/feishu Feishu / Lark adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants