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: 修复切换模式服务无响应的问题

douranc9654ba4a063
diff --git a/jiuwenclaw/channel/feishu.py b/jiuwenclaw/channel/feishu.py
index 590989ca0e..e1b55a577d 100644
--- a/jiuwenclaw/channel/feishu.py
+++ b/jiuwenclaw/channel/feishu.py
@@ -926,7 +926,13 @@ class FeishuChannel(BaseChannel):
@staticmethod
def _is_control_message(content: str) -> bool:
text = content.strip()
- return text in {"/new_session", "/mode plan", "/mode agent", "/mode team"}
+ if not text or "\n" in text:
+ return False
+ if text == "/new_session":
+ return True
+ if text.startswith("/mode "):
+ return True
+ return False
async def _enqueue_message_batch(
self,
diff --git a/jiuwenclaw/gateway/message_handler.py b/jiuwenclaw/gateway/message_handler.py
index 9c3ae446cd..7603bee470 100644
--- a/jiuwenclaw/gateway/message_handler.py
+++ b/jiuwenclaw/gateway/message_handler.py
@@ -333,6 +333,15 @@ class MessageHandler(ABC):
if old_sid is None and not rids_cancelled:
return
+ # 非流式场景不向 AgentServer 下发 cancel,避免无在途流式任务时触发不必要的中断逻辑。
+ if not bool(getattr(msg, "is_stream", False)):
+ logger.info(
+ "[MessageHandler] 跳过 AgentServer cancel(非流式): channel_id=%s session_id=%s",
+ msg.channel_id,
+ old_sid,
+ )
+ return
+
cancel_req = Message(
id=f"interrupt_{int(time.time() * 1000):x}_{secrets.token_hex(3)}",
type="req",
@@ -447,7 +456,7 @@ class MessageHandler(ABC):
)
)
return True
- elif "/new_session" in text:
+ elif "\n" not in text and text.startswith("/new_session"):
asyncio.create_task(
self._send_channel_notice(
user_infos,
@@ -495,7 +504,7 @@ class MessageHandler(ABC):
)
)
return True
- elif "/mode" in text:
+ elif "\n" not in text and text.startswith("/mode"):
asyncio.create_task(
self._send_channel_notice(
user_infos,