Revert "fix(feishu): streaming card and tool hint respect reply_to_message in…"

This reverts commit 651b6b933f.
This commit is contained in:
Xubin Ren
2026-04-30 13:27:37 +08:00
parent 651b6b933f
commit 26e953f0b9
2 changed files with 14 additions and 110 deletions
-87
View File
@@ -728,90 +728,3 @@ def test_on_background_task_done_removes_from_set() -> None:
loop.close()
assert task not in channel._background_tasks
# ---------------------------------------------------------------------------
# Issue #3533: streaming card / tool hint must respect reply_to_message
# ---------------------------------------------------------------------------
@pytest.mark.parametrize(
("reply_to_message", "meta", "expected"),
[
(True, {"chat_type": "p2p", "message_id": "om_1"}, None),
(False, {"chat_type": "group", "message_id": "om_1"}, None),
(True, {"chat_type": "group", "message_id": "om_1"}, "om_1"),
(False, {"chat_type": "group", "message_id": "om_1", "thread_id": "ot_1"}, "om_1"),
(True, {"chat_type": "group"}, None),
],
)
def test_thread_reply_target_gating(reply_to_message, meta, expected) -> None:
channel = _make_feishu_channel(reply_to_message=reply_to_message)
assert channel._thread_reply_target(meta) == expected
@pytest.mark.asyncio
async def test_tool_hint_skips_reply_for_top_level_group_when_disabled() -> None:
"""Bug case: tool-hint card on a top-level group msg must NOT spawn a topic."""
channel = _make_feishu_channel(reply_to_message=False)
create_resp = MagicMock()
create_resp.success.return_value = True
create_resp.data = SimpleNamespace(message_id="om_hint")
channel._client.im.v1.message.create.return_value = create_resp
await channel.send(OutboundMessage(
channel="feishu", chat_id="oc_abc", content='web_search("q")',
metadata={"_tool_hint": True, "message_id": "om_user", "chat_type": "group"},
))
channel._client.im.v1.message.create.assert_called_once()
channel._client.im.v1.message.reply.assert_not_called()
@pytest.mark.asyncio
async def test_streaming_card_skips_reply_for_top_level_group_when_disabled() -> None:
"""Bug case: first streaming delta on a top-level group msg must NOT spawn a topic."""
channel = _make_feishu_channel(reply_to_message=False)
card_resp = MagicMock()
card_resp.success.return_value = True
card_resp.data = SimpleNamespace(card_id="card_1")
channel._client.cardkit.v1.card.create.return_value = card_resp
send_resp = MagicMock()
send_resp.success.return_value = True
send_resp.data = SimpleNamespace(message_id="om_card")
channel._client.im.v1.message.create.return_value = send_resp
update_resp = MagicMock()
update_resp.success.return_value = True
channel._client.cardkit.v1.card_element.content.return_value = update_resp
await channel.send_delta(
"oc_abc", "hello",
metadata={"message_id": "om_user", "chat_type": "group"},
)
channel._client.im.v1.message.create.assert_called_once()
channel._client.im.v1.message.reply.assert_not_called()
@pytest.mark.asyncio
async def test_streaming_card_keeps_reply_in_topic_even_when_disabled() -> None:
"""Regression guard: in-topic continuation must keep using Reply API
so the response stays inside the existing topic — independent of config."""
channel = _make_feishu_channel(reply_to_message=False)
card_resp = MagicMock()
card_resp.success.return_value = True
card_resp.data = SimpleNamespace(card_id="card_1")
channel._client.cardkit.v1.card.create.return_value = card_resp
reply_resp = MagicMock()
reply_resp.success.return_value = True
channel._client.im.v1.message.reply.return_value = reply_resp
update_resp = MagicMock()
update_resp.success.return_value = True
channel._client.cardkit.v1.card_element.content.return_value = update_resp
await channel.send_delta(
"oc_abc", "hello",
metadata={"message_id": "om_user", "chat_type": "group", "thread_id": "ot_1"},
)
channel._client.im.v1.message.reply.assert_called_once()