Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix: feishu channel 非流式输出不支持team 模式 & agent多实例 & xiaoyi流式结束信号

ray_le1344aed31878
diff --git a/jiuwenclaw/agentserver/agent_manager.py b/jiuwenclaw/agentserver/agent_manager.py
index 4858554773..2882642c0e 100644
--- a/jiuwenclaw/agentserver/agent_manager.py
+++ b/jiuwenclaw/agentserver/agent_manager.py
@@ -152,13 +152,12 @@ class AgentManager:
Returns:
JiuWenClaw | None: Agent 实例
"""
- agent_key = channel_id if channel_id == "acp" else "default"
- if agent_key not in self.agents:
+ if channel_id not in self.agents:
config: dict[str, Any] | None = None
if channel_id == "acp":
config = _build_acp_agent_config()
- await self._create_agent(agent_key, config)
- return self.agents.get(agent_key)
+ await self._create_agent(channel_id, config)
+ return self.agents.get(channel_id)
def get_agent_nowait(self, channel_id: str = "") -> "JiuWenClaw | None":
"""获取 Agent 实例(同步,不自动创建).
diff --git a/jiuwenclaw/channel/feishu.py b/jiuwenclaw/channel/feishu.py
index 0cf765ceb3..adf62ca4c3 100644
--- a/jiuwenclaw/channel/feishu.py
+++ b/jiuwenclaw/channel/feishu.py
@@ -2020,6 +2020,29 @@ class FeishuChannel(BaseChannel):
# 解析消息内容(支持文件类型)
content, file_info = await self._parse_message_content_with_file(message)
+ if content == "/mode team" and self.config.enable_streaming == False:
+ # 非流式情况下不支持team模式,向用户发送提示
+ try:
+ # 提取发送者open_id
+ open_id = (
+ getattr(getattr(sender, "sender_id", None), "open_id", None) or ""
+ )
+ # 获取chat_id和判断ID类型
+ chat_id = getattr(message, "chat_id", None) or ""
+ if chat_id.startswith("oc_"):
+ receive_id = chat_id
+ id_type = "chat_id"
+ else:
+ # 私聊场景使用open_id
+ receive_id = open_id
+ id_type = "open_id"
+ hint_text = "⚠️ 非流式模式下不支持 Team 模式,已保持原有模式。\n\n" \
+ "如需使用 Team 模式,请在配置中开启流式输出 (enable_streaming: true)。"
+ card = self._build_card_content(hint_text)
+ await self._send_feishu_message(receive_id, id_type, card, message.message_id)
+ except Exception as e:
+ logger.warning(f"[FeishuChannel] 发送Team模式提示失败: {e}")
+ return
if not content and not file_info:
return
diff --git a/jiuwenclaw/channel/xiaoyi_utils/formatter.py b/jiuwenclaw/channel/xiaoyi_utils/formatter.py
index cc23018803..083045ea99 100644
--- a/jiuwenclaw/channel/xiaoyi_utils/formatter.py
+++ b/jiuwenclaw/channel/xiaoyi_utils/formatter.py
@@ -556,8 +556,7 @@ def should_send_as_status_update(event_type: EventType | None) -> bool:
# - CHAT_PROCESSING_STATUS: 处理状态
status_events = {
EventType.CHAT_TOOL_CALL,
- EventType.CHAT_TOOL_RESULT,
- EventType.CHAT_PROCESSING_STATUS,
+ EventType.CHAT_TOOL_RESULT
}
return event_type in status_events
diff --git a/jiuwenclaw/gateway/message_handler.py b/jiuwenclaw/gateway/message_handler.py
index 7603bee470..c7ae629d66 100644
--- a/jiuwenclaw/gateway/message_handler.py
+++ b/jiuwenclaw/gateway/message_handler.py
@@ -1584,6 +1584,7 @@ class MessageHandler(ABC):
"event_type": "chat.processing_status",
"session_id": session_id,
"is_processing": is_processing,
+ "is_complete": not is_processing
},
event_type=EventType.CHAT_PROCESSING_STATUS,
metadata=None,