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(agent-teams): In team mode, messages from IM channels (e.g., Feishu) are sent by teammates, not the main user, and won't show in the main chat panel.

tangfei03062536a8fe90a3
diff --git a/jiuwenswarm/gateway/message_handler/join_exit_handlers.py b/jiuwenswarm/gateway/message_handler/join_exit_handlers.py
index 6dcb1bdf87..a4f1bee1a0 100644
--- a/jiuwenswarm/gateway/message_handler/join_exit_handlers.py
+++ b/jiuwenswarm/gateway/message_handler/join_exit_handlers.py
@@ -32,6 +32,9 @@ if TYPE_CHECKING:
logger = logging.getLogger(__name__)
+# Team seat ownership is implemented only for these IM channels.
+_TEAM_SEAT_SUPPORTED_CHANNELS: frozenset[str] = frozenset({"feishu", "xiaoyi"})
+
# 已 /join 认领 team 席位后仍允许执行的控制指令白名单。
# 其余会改变 session/mode/分支/对话历史或向 Agent 注入 query 的执行类指令一律拒绝
@@ -121,6 +124,16 @@ class JoinExitHandlers:
parsed: "ParsedChannelControl",
) -> None:
"""处理 /join 指令:注册到 SessionSharingRegistry 并发送确认."""
+ # Reject unsupported channels before any lookup or registration can
+ # create partial state.
+ if str(msg.channel_id).lower() not in _TEAM_SEAT_SUPPORTED_CHANNELS:
+ await self._h.send_channel_notice(
+ user_infos,
+ channel_id,
+ msg.session_id,
+ "当前通道暂不支持 /join,仅飞书和小艺支持加入团队。",
+ )
+ return
sid = self._h.extract_session_id_from_ref(parsed.session_ref)
if not sid or not parsed.member_name:
await self._h.send_channel_notice(
@@ -552,6 +565,14 @@ class JoinExitHandlers:
parsed: "ParsedChannelControl",
) -> None:
"""处理 /exit 指令:从 SessionSharingRegistry 注销并发送确认."""
+ if str(msg.channel_id).lower() not in _TEAM_SEAT_SUPPORTED_CHANNELS:
+ await self._h.send_channel_notice(
+ user_infos,
+ channel_id,
+ msg.session_id,
+ "当前通道暂不支持 /exit,仅飞书和小艺支持退出团队。",
+ )
+ return
sid = self._h.extract_session_id_from_ref(parsed.session_ref)
if not sid:
# 不带 session_ref:直接用 msg.session_id。handle_message 入队前已对已 /join
diff --git a/jiuwenswarm/server/agent_ws_server.py b/jiuwenswarm/server/agent_ws_server.py
index 20795862e0..2f82efeca3 100644
--- a/jiuwenswarm/server/agent_ws_server.py
+++ b/jiuwenswarm/server/agent_ws_server.py
@@ -390,6 +390,11 @@ def _is_restorable_history_record(record: Any) -> bool:
)
if role == "user":
+ mode = record.get("mode", "")
+ if mode in ("team", "team.plan", "code.team"):
+ channel_id = record.get("channel_id", "")
+ if channel_id not in ("web", "tui"):
+ return False
return has_content or has_media
event_type = record.get("event_type")