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(team):In team mode, it is impossible to determine what mode the current situation is.

openJiuwen-bota26885b6b897
diff --git a/jiuwenswarm/agents/swarm/providers/member_rails.py b/jiuwenswarm/agents/swarm/providers/member_rails.py
index 59b224ec12..2f33ccd145 100644
--- a/jiuwenswarm/agents/swarm/providers/member_rails.py
+++ b/jiuwenswarm/agents/swarm/providers/member_rails.py
@@ -166,6 +166,11 @@ def _build_runtime_prompt_rail(
"""
inp = RuntimePromptInput.resolve(params, context)
rail = RuntimePromptRail(language=inp.language, channel=inp.channel)
+ # Team members use their own RuntimePromptRail instance. Bind it to the
+ # originating request so runtime state is read from the active session
+ # instead of the process-wide ``default`` state file.
+ rail.set_mode(context.mode)
+ rail.set_session_id(context.session_id)
# Seed cwd/project_dir so the TUI branch injects the "current project
# directory" policy and the model answers with the project dir instead of
# calling `pwd` (which would surface the per-member workspace path).
diff --git a/jiuwenswarm/cli/chat.py b/jiuwenswarm/cli/chat.py
index 1e9e61f725..5830b02615 100644
--- a/jiuwenswarm/cli/chat.py
+++ b/jiuwenswarm/cli/chat.py
@@ -213,7 +213,7 @@ MODE_ALIASES: dict[str, str] = {
# plan / fast 已合并为单一 agent 模式;agent.plan / agent.fast 作为历史别名仍可接受,归一到 agent。
VALID_MODES = frozenset({
- "agent", "agent.plan", "agent.fast", "code.plan", "code.normal", "code.team", "team",
+ "agent", "agent.plan", "agent.fast", "code.plan", "code.normal", "code.team", "team", "team.plan",
})
# Sources that require the answer to be sent via ``chat.send`` (streaming) to
@@ -262,7 +262,7 @@ def build_parser() -> argparse.ArgumentParser:
)
p.add_argument(
"--mode", default="code.normal",
- help="Execution mode: agent|code|team|code.plan|code.normal|code.team"
+ help="Execution mode: agent|code|team|team.plan|code.plan|code.normal|code.team"
" (default: code.normal).",
)
p.add_argument(
diff --git a/jiuwenswarm/resources/config.yaml b/jiuwenswarm/resources/config.yaml
index e03916f368..f0131ecbab 100644
--- a/jiuwenswarm/resources/config.yaml
+++ b/jiuwenswarm/resources/config.yaml
@@ -1020,6 +1020,11 @@ modes:
spawn_mode: inprocess
enable_swarmflow: false
+ # Enable the host-managed worktree capability used by team members and
+ # SwarmFlow agent calls with options.isolation="worktree".
+ worktree:
+ enabled: true
+
# Team-specific permission control.
enable_permissions: false
diff --git a/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py b/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py
index 180d20722a..cf2f151655 100644
--- a/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py
+++ b/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py
@@ -520,6 +520,8 @@ _MODE_DISPLAY_MAP: dict[str, dict[str, str]] = {
"agent.plan": {"cn": "智能体模式", "en": "Agent Mode"},
"agent.fast": {"cn": "智能体模式", "en": "Agent Mode"},
"team": {"cn": "集群模式", "en": "Cluster Mode"},
+ "team.plan": {"cn": "集群计划模式", "en": "Cluster Plan Mode"},
+ "code.team": {"cn": "代码集群模式", "en": "Code Team Mode"},
}
diff --git a/tests/agents/swarm/test_swarm_assembly.py b/tests/agents/swarm/test_swarm_assembly.py
index 5a6ecb031c..9a6de27550 100644
--- a/tests/agents/swarm/test_swarm_assembly.py
+++ b/tests/agents/swarm/test_swarm_assembly.py
@@ -86,6 +86,16 @@ from jiuwenswarm.common.config import get_config
logger = logging.getLogger(__name__)
+
[email protected]("mode", ["team", "team.plan", "code.team"])
+def test_member_runtime_prompt_rail_binds_request_identity(mode: str) -> None:
+ context = SwarmBuildContext(session_id="session-123", mode=mode)
+
+ rail = member_rails._build_runtime_prompt_rail({}, context)
+
+ assert rail._session_id == "session-123"
+ assert rail._mode == mode
+
# Rail provider names shared by both roles (no role-specific evolution rails).
# Sourced from the registry symbols so the test tracks renames automatically.
_COMMON_RAIL_NAMES: frozenset[str] = frozenset(
diff --git a/tests/unit_tests/cli/test_chat.py b/tests/unit_tests/cli/test_chat.py
index 09e68e6118..98d9b6222d 100644
--- a/tests/unit_tests/cli/test_chat.py
+++ b/tests/unit_tests/cli/test_chat.py
@@ -46,6 +46,7 @@ class TestResolveMode:
assert resolve_mode("code.plan") == "code.plan"
assert resolve_mode("code.team") == "code.team"
assert resolve_mode("team") == "team"
+ assert resolve_mode("team.plan") == "team.plan"
@staticmethod
def test_alias_resolution():
diff --git a/tests/unit_tests/test_resource_config.py b/tests/unit_tests/test_resource_config.py
index fa09759474..26c154a795 100644
--- a/tests/unit_tests/test_resource_config.py
+++ b/tests/unit_tests/test_resource_config.py
@@ -3,6 +3,15 @@ from pathlib import Path
import yaml
+def test_default_team_config_enables_managed_worktrees():
+ repo_root = Path(__file__).resolve().parents[2]
+ config_file = repo_root / "jiuwenswarm" / "resources" / "config.yaml"
+
+ data = yaml.safe_load(config_file.read_text(encoding="utf-8"))
+
+ assert data["modes"]["team"]["jiuwen_team"]["worktree"] == {"enabled": True}
+
+
def test_default_round_level_compressor_config_uses_context_ratio():
repo_root = Path(__file__).resolve().parents[2]
config_files = [