fix(feishu): keep topic replies in active threads - #18385
Conversation
Carry the inbound Feishu message id through topic metadata so replies use the reply API with reply_in_thread, and add an opt-in thread-follow window that lets a mentioned topic continue without repeated @mentions.
- Avoid refreshing topic-follow TTL from unmentioned follow-up messages - Carry Feishu reply_to_message_id through /background result sends - Prune expired topic-follow entries and cover edge cases with tests
|
Follow-up review + hardening update for the Feishu topic-thread fix. What changed after the review:
Verification performed locally:
Known unrelated local suite note:
Deployment safety note:
|
Follow-up verification after reviewI did a post-PR verification pass and pushed one hardening commit ( What changed in the follow-up commit
Verification
Non-blocking follow-ups noted
|
|
Reproduces in another shared-gateway deployment — exact symptom: bot @-mentioned inside a topic group reply ends up in a brand-new sub-thread instead of staying in the active topic. The dual fix here (carry |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the detailed Feishu threading work. Current main already covers the core reply-in-topic behavior through 441ef75d1 and the plugin adapter's metadata reply path (plugins/platforms/feishu/adapter.py:4609-4621), but the proposed opt-in follow window remains distinct.
Problems
gateway/platforms/feishu.py:3804keys follow state only frommessage.thread_id. Admission runs before inbound normalization (plugins/platforms/feishu/adapter.py:2536), while the normalized topic ID explicitly falls back tomessage.root_id(plugins/platforms/feishu/adapter.py:3252). Root-ID-only topic events therefore cannot activate or consume the follow TTL.- The PR modifies the former adapter path. Feishu now owns YAML handling through
plugins/platforms/feishu/adapter.py:5618-5654; the current patch cannot be cleanly applied to main. gateway/platforms/feishu.py:1528and:1532add new non-secretHERMES_*configuration fallbacks, contrary to the config.yaml-only policy inAGENTS.md:102-106.
Suggested changes
- Use
thread_id or root_idfor the admission-time follow key and add an end-to-end adapter test for a root-ID-only topic event. - Salvage the remaining follow-window feature into the Feishu plugin/config hook, using config values rather than new environment variables.
This is an automated hermes-sweeper review.
|
|
||
| def _thread_follow_key(self, message: Any) -> Optional[tuple[str, str]]: | ||
| chat_id = str(getattr(message, "chat_id", "") or "").strip() | ||
| thread_id = str(getattr(message, "thread_id", "") or "").strip() |
There was a problem hiding this comment.
Topic events can expose root_id without thread_id. _admit runs before _process_inbound_message, where current main normalizes the topic as thread_id or root_id; this leaves the follow key empty and prevents the TTL from activating. Use the same root fallback here and cover the full inbound path.
Summary
om_...message id asreply_to_message_idreply_in_thread=Trueinstead of only carryingomt_...topic idfeishu.thread_follow_enabled,feishu.thread_follow_ttl_seconds) so a mentioned topic can continue without repeated @mentions until TTL expiryMEDIA:<path>image/file delivery through the same Feishu topic metadata helper so native attachments also reply inside the originating topicTest Plan
python -m py_compile gateway/platforms/feishu.py tests/gateway/test_feishu_bot_admission.py./venv/bin/python -m py_compile gateway/run.py gateway/platforms/feishu.py gateway/config.py tests/gateway/test_feishu_bot_admission.py./venv/bin/python -m pytest tests/gateway/test_feishu.py tests/gateway/test_feishu_bot_admission.py tests/gateway/test_run_progress_topics.py -q/root/.hermes/scripts/hermes-feishu-topic-patch-verify.shResult: 292 passed, 8 dependency deprecation warnings.