mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-15 04:12:25 +00:00
fix(feishu): keep topic replies in threads
Route Feishu topic progress, status, approval, stream, and fallback messages through threaded replies by preserving the originating message id as the reply target. Add regressions for tool progress topic metadata and Feishu metadata-driven reply routing.
This commit is contained in:
parent
48c241840a
commit
441ef75d15
4 changed files with 121 additions and 6 deletions
|
|
@ -1962,6 +1962,45 @@ class TestAdapterBehavior(unittest.TestCase):
|
|||
self.assertEqual(result.message_id, "om_reply")
|
||||
self.assertTrue(captured["request"].request_body.reply_in_thread)
|
||||
|
||||
@patch.dict(os.environ, {}, clear=True)
|
||||
def test_send_uses_metadata_reply_target_for_threaded_feishu_topic(self):
|
||||
from gateway.config import PlatformConfig
|
||||
from gateway.platforms.feishu import FeishuAdapter
|
||||
|
||||
adapter = FeishuAdapter(PlatformConfig())
|
||||
captured = {}
|
||||
|
||||
class _MessageAPI:
|
||||
def reply(self, request):
|
||||
captured["request"] = request
|
||||
return SimpleNamespace(
|
||||
success=lambda: True,
|
||||
data=SimpleNamespace(message_id="om_reply"),
|
||||
)
|
||||
|
||||
adapter._client = SimpleNamespace(
|
||||
im=SimpleNamespace(v1=SimpleNamespace(message=_MessageAPI()))
|
||||
)
|
||||
|
||||
async def _direct(func, *args, **kwargs):
|
||||
return func(*args, **kwargs)
|
||||
|
||||
with patch("gateway.platforms.feishu.asyncio.to_thread", side_effect=_direct):
|
||||
result = asyncio.run(
|
||||
adapter.send(
|
||||
chat_id="oc_chat",
|
||||
content="status update",
|
||||
metadata={
|
||||
"thread_id": "omt-thread",
|
||||
"reply_to_message_id": "om_trigger",
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
self.assertTrue(result.success)
|
||||
self.assertEqual(captured["request"].message_id, "om_trigger")
|
||||
self.assertTrue(captured["request"].request_body.reply_in_thread)
|
||||
|
||||
@patch.dict(os.environ, {}, clear=True)
|
||||
def test_send_retries_transient_failure(self):
|
||||
from gateway.config import PlatformConfig
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue