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

update(mode): remove /mode agent

douran70a9c0e18d04
diff --git a/docs/en/CLI.md b/docs/en/CLI.md
index b1f13ce961..c6d8f28f06 100644
--- a/docs/en/CLI.md
+++ b/docs/en/CLI.md
@@ -3,7 +3,7 @@
JiuwenClaw supports **special prefix commands** to control sessions and modes. Common ones:
- `/new_session`: start a new `session_id` for the current channel
-- `/mode plan` or `/mode agent`: switch the channel’s working mode
+- `/mode plan`, `/mode fast`, or `/mode team`: switch the channel’s working mode
These are handled in the Gateway **`MessageHandler`** and **are not** sent to the agent.
@@ -41,13 +41,14 @@ The Gateway will:
---
-### 2. `/mode` — channel mode (`plan` / `agent`)
+### 2. `/mode` — channel mode (`plan` / `fast` / `team`)
**Behavior**
- Sets a logical **mode** for the channel:
- `plan`: planning, explanation, decomposition (default)
- - `agent`: more hands-on execution
+ - `fast`: more hands-on execution (same internal semantics as the historical `agent` mode)
+ - `team`: team mode
- Mode is passed in `params["mode"]` for prompt construction.
**Usage**
@@ -59,14 +60,14 @@ The Gateway will:
or
```text
- /mode agent
+ /mode fast
```
The Gateway will:
1. Treat as control, not forward to the agent
2. Update `ChannelControlState.mode`
- 3. Reply e.g. `mode updated to agent`
+ 3. Reply e.g. `mode updated to fast`
**Scope**
diff --git a/docs/zh/SLASH_COMMAND_ARCHITECTURE.md b/docs/zh/SLASH_COMMAND_ARCHITECTURE.md
index f6eda8a358..b28f965da4 100644
--- a/docs/zh/SLASH_COMMAND_ARCHITECTURE.md
+++ b/docs/zh/SLASH_COMMAND_ARCHITECTURE.md
@@ -39,7 +39,7 @@
**定义**:到达 Gateway 用户消息中,由 `MessageHandler`(或其后继统一入口)识别后,**可能只改会话/模式/路由,而不进入 Agent 对话**的指令。
-**典型**:`/new_session`、受控通道上的 `/mode plan|agent|fast|team`(以当前实现为准)。
+**典型**:`/new_session`、受控通道上的 `/mode plan|fast|team`(以当前实现为准)。
**要求**:
@@ -63,7 +63,7 @@
**要求**:
-- 在 SSOT 或文档矩阵中增加 **`canonical_name` + `cli_alias`** 等字段,避免「CLI 叫 `/fast`、IM 只认 `/mode agent`」时无据可查。
+- 在 SSOT 或文档矩阵中增加 **`canonical_name` + `cli_alias`** 等字段,避免「CLI 与 IM 斜杠写法不一致」时无据可查。
- Gateway **不必**理解 CLI 别名;若未来需要服务端识别,应显式列为新需求并扩展协议,而非隐式复用用户输入字符串。
---
diff --git "a/docs/zh/\345\221\275\344\273\244\350\241\214\346\214\207\344\273\244.md" "b/docs/zh/\345\221\275\344\273\244\350\241\214\346\214\207\344\273\244.md"
index cbb5b79e0e..69079f14de 100644
--- "a/docs/zh/\345\221\275\344\273\244\350\241\214\346\214\207\344\273\244.md"
+++ "b/docs/zh/\345\221\275\344\273\244\350\241\214\346\214\207\344\273\244.md"
@@ -3,7 +3,7 @@
JiuwenClaw 支持通过「特殊前缀指令」控制会话和模式,最常用的是:
- `/new_session`:为当前通道切换到一个全新的 `session_id`
-- `/mode plan` 或 `/mode agent`:切换当前通道的工作模式
+- `/mode plan`、`/mode fast` 或 `/mode team`:切换当前通道的工作模式
这些指令由 Gateway 层的 `MessageHandler` 解析,**不会发给 Agent 本身**。
@@ -40,13 +40,14 @@ JiuwenClaw 支持通过「特殊前缀指令」控制会话和模式,最常用
---
-### 2. `/mode` —— 切换通道模式(plan / agent)
+### 2. `/mode` —— 切换通道模式(plan / fast / team)
**作用:**
- 为当前通道设置一个逻辑「模式」,用于告诉 Agent 是偏向:
- `plan`:偏规划、解释、拆解任务(默认)
- - `agent`:偏自动执行、直接动手
+ - `fast`:偏自动执行、直接动手(内部与历史 `agent` 模式一致)
+ - `team`:组队模式
- 模式信息会写入消息的 `params["mode"]` 中,Agent 在构造提示词和行为策略时可以使用。
**使用方式:**
@@ -60,14 +61,14 @@ JiuwenClaw 支持通过「特殊前缀指令」控制会话和模式,最常用
或
```text
- /mode agent
+ /mode fast
```
- Gateway 会:
1. 识别这条消息为控制指令,不转发给 Agent
2. 更新内部 `ChannelControlState.mode`
3. 给当前会话回复一条系统提示,例如:
- `mode 已变更为 agent`
+ `mode 已变更为 fast`
**生效范围:**
diff --git a/jiuwenclaw/gateway/message_handler.py b/jiuwenclaw/gateway/message_handler.py
index c6f9ffb047..20e93a2a2a 100644
--- a/jiuwenclaw/gateway/message_handler.py
+++ b/jiuwenclaw/gateway/message_handler.py
@@ -118,7 +118,7 @@ class MessageHandler(ABC):
self._stream_tasks: dict[str, asyncio.Task] = {} # request_id -> task
self._stream_sessions: dict[str, str | None] = {} # request_id -> session_id
self._stream_metadata: dict[str, dict[str, Any] | None] = {} # request_id -> request metadata
- self._stream_modes: dict[str, str] = {} # request_id -> mode (plan/agent)
+ self._stream_modes: dict[str, str] = {} # request_id -> mode (plan/agent/team)
self._pending_evolution_approval: dict[str, str] = {} # session_id -> approval_request_id
self._queued_supplement_input: dict[str, str] = {} # session_id -> queued_new_input
self._session_evolution_in_progress: set[str] = set()
@@ -204,7 +204,12 @@ class MessageHandler(ABC):
if not sid:
sid = self._generate_channel_session_id(channel_id)
mode_raw = str(ch_cfg.get("default_mode") or "plan").strip().lower()
- mode = ChannelMode.AGENT if mode_raw == "agent" else ChannelMode.PLAN
+ if mode_raw in ("agent", "fast"):
+ mode = ChannelMode.AGENT
+ elif mode_raw == "team":
+ mode = ChannelMode.TEAM
+ else:
+ mode = ChannelMode.PLAN
return ChannelControlState(session_id=sid, mode=mode)
def _get_channel_state_key(self, channel_id: str, conversation_id: str | None) -> str:
@@ -414,12 +419,8 @@ class MessageHandler(ABC):
@staticmethod
def _build_mode_change_notice_text(mode_label: str) -> str:
- base = f"[收到 CLI 指令], mode 已变更为 {mode_label}"
- if mode_label == ChannelMode.AGENT.value:
- return (
- f"{base}。为统一命名体系,后续将逐步以 fast 作为该执行模式的标准名称。"
- )
- return base
+ display = "fast" if mode_label == ChannelMode.AGENT.value else mode_label
+ return f"[收到 CLI 指令], mode 已变更为 {display}"
def _handle_channel_control(self, msg: "Message") -> bool:
r"""处理 \new_session / \mode / \skills 指令.
@@ -495,7 +496,7 @@ class MessageHandler(ABC):
if parsed.action is ParsedControlAction.MODE_OK:
mode_str = parsed.mode_subcommand or ""
- if mode_str not in ("plan", "agent", "fast", "team"):
+ if mode_str not in ("plan", "fast", "team"):
asyncio.create_task(
self._send_channel_notice(
user_infos,
@@ -507,7 +508,7 @@ class MessageHandler(ABC):
return True
old_mode = state.mode
old_sid = state.session_id
- if mode_str in ("agent", "fast"):
+ if mode_str == "fast":
state.mode = ChannelMode.AGENT
elif mode_str == "team":
state.mode = ChannelMode.TEAM
diff --git a/jiuwenclaw/gateway/slash_command.py b/jiuwenclaw/gateway/slash_command.py
index 2ac558227c..cf27ef90eb 100644
--- a/jiuwenclaw/gateway/slash_command.py
+++ b/jiuwenclaw/gateway/slash_command.py
@@ -30,7 +30,6 @@ class ModeSubcommand(str, Enum):
"""`/mode` 支持的子命令。"""
PLAN = "plan"
- AGENT = "agent"
FAST = "fast"
TEAM = "team"
@@ -61,7 +60,7 @@ class ParsedChannelControl:
action: ParsedControlAction
mode_subcommand: str | None = None
- """mode_ok 时为 plan|agent|fast|team 之一。"""
+ """mode_ok 时为 plan|fast|team 之一。"""
def parse_channel_control_text(text: str) -> ParsedChannelControl:
@@ -141,7 +140,7 @@ FIRST_BATCH_REGISTRY: tuple[SlashCommandEntry, ...] = (
),
SlashCommandEntry(
id="mode",
- canonical_text=f"{GatewaySlashCommand.MODE.value} plan|agent|fast|team",
+ canonical_text=f"{GatewaySlashCommand.MODE.value} plan|fast|team",
scope="gateway",
req_method=None,
notes="受控通道切换 ChannelMode;写入 params.mode。",
diff --git a/tests/unit_tests/gateway/test_slash_command.py b/tests/unit_tests/gateway/test_slash_command.py
index 9496631034..c7a95efc49 100644
--- a/tests/unit_tests/gateway/test_slash_command.py
+++ b/tests/unit_tests/gateway/test_slash_command.py
@@ -35,7 +35,7 @@ parse_channel_control_text = _MOD.parse_channel_control_text
("/new_session", ParsedControlAction.NEW_SESSION_OK, None),
("/new_session x", ParsedControlAction.NEW_SESSION_BAD, None),
("/mode plan", ParsedControlAction.MODE_OK, "plan"),
- ("/mode agent", ParsedControlAction.MODE_OK, "agent"),
+ ("/mode agent", ParsedControlAction.MODE_BAD, None),
("/mode fast", ParsedControlAction.MODE_OK, "fast"),
("/mode team", ParsedControlAction.MODE_OK, "team"),
("/mode claw", ParsedControlAction.MODE_BAD, None),