fix(feishu): unconditionally inc streaming sequence to prevent locking; send fallback as normal msg

This commit is contained in:
jxxghp
2026-05-13 08:08:59 +08:00
parent ea8a90aa0a
commit b6062a9ce2
2 changed files with 8 additions and 4 deletions

View File

@@ -663,7 +663,7 @@ class MoviePilotAgent:
and self.should_dispatch_reply
and not self._tool_context.get("user_reply_sent")
):
await self.send_agent_message(remaining_text)
await self.send_agent_message(remaining_text, is_streaming_fallback=True)
elif (
remaining_text
and self.persist_output_message
@@ -743,17 +743,20 @@ class MoviePilotAgent:
# 确保停止流式输出
await self.stream_handler.stop_streaming()
async def send_agent_message(self, message: str, title: str = ""):
async def send_agent_message(self, message: str, title: str = "", is_streaming_fallback: bool = False):
"""
通过原渠道发送消息给用户
"""
mtype = NotificationType.System if is_streaming_fallback else NotificationType.Agent
await AgentChain().async_post_message(
Notification(
channel=self.channel,
source=self.source,
mtype=NotificationType.Agent,
mtype=mtype,
userid=self.user_id,
username=self.username,
original_message_id=self.original_message_id,
original_chat_id=self.original_chat_id,
title=title,
text=message,
)

View File

@@ -1240,13 +1240,14 @@ class Feishu:
card_id = str(stream_meta.get("card_id") or "").strip()
element_id = str(stream_meta.get("element_id") or self.STREAM_CARD_BODY_ELEMENT_ID).strip()
sequence = int(stream_meta.get("sequence") or 0) + 1
# 无论远端是否响应成功都自增 sequence防止某次超时导致后续 sequence 一直因为没有递增而被拒绝
stream_meta["sequence"] = sequence
if card_id and element_id and self._update_streaming_card_content(
card_id=card_id,
element_id=element_id,
content=self._escape_card_text(text).strip() or " ",
sequence=sequence,
):
stream_meta["sequence"] = sequence
return True
card = self._build_card(title=title, text=text, link=None, buttons=buttons)