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
飞书team模式-调用team skill,会话返回的生成评审备忘录目录不正确
weichenhao3e9dfd6f1dd3
diff --git a/jiuwenclaw/agentserver/team/rails/__init__.py b/jiuwenclaw/agentserver/team/rails/__init__.pynew file mode 100644index 0000000000..c13bbb8991--- /dev/null+++ b/jiuwenclaw/agentserver/team/rails/__init__.py@@ -0,0 +1,9 @@+# Copyright (c) Huawei Technologies Co., Ltd. 2026. All rights reserved.++"""Rails used by team runtime helpers."""++from jiuwenclaw.agentserver.team.rails.team_workspace_report_path_rail import (+ TeamWorkspaceReportPathRail,+)++__all__ = ["TeamWorkspaceReportPathRail"]diff --git a/jiuwenclaw/agentserver/team/rails/team_workspace_report_path_rail.py b/jiuwenclaw/agentserver/team/rails/team_workspace_report_path_rail.pynew file mode 100644index 0000000000..65dbbfc532--- /dev/null+++ b/jiuwenclaw/agentserver/team/rails/team_workspace_report_path_rail.py@@ -0,0 +1,64 @@+# Copyright (c) Huawei Technologies Co., Ltd. 2026. All rights reserved.++"""Prompt rail for reporting real team workspace artifact paths."""++from __future__ import annotations++from pathlib import Path++from openjiuwen.core.single_agent.rail.base import AgentCallbackContext+from openjiuwen.harness.prompts import PromptSection+from openjiuwen.harness.rails.base import DeepAgentRail+++class TeamWorkspaceReportPathRail(DeepAgentRail):+ """Inject guidance for reporting real shared-workspace artifact paths."""++ priority = 5++ def __init__(+ self,+ *,+ root_dir: str,+ team_id: str | None = None,+ language: str = "cn",+ ) -> None:+ super().__init__()+ self.system_prompt_builder = None+ self._root_dir = str(Path(root_dir))+ self._team_id = team_id or ""+ self._language = language++ def init(self, agent) -> None:+ self.system_prompt_builder = getattr(agent, "system_prompt_builder", None)++ def uninit(self, agent) -> None:+ if self.system_prompt_builder is not None:+ self.system_prompt_builder.remove_section("team_workspace_report_paths")+ self.system_prompt_builder = None++ async def before_model_call(self, ctx: AgentCallbackContext) -> None:+ _ = ctx+ if self.system_prompt_builder is None:+ return++ mount = f".team/{self._team_id}/" if self._team_id else ".team/"+ sample = str(Path(self._root_dir) / "prd-review-memo.md")+ content = (+ "# Team Workspace Artifact Paths\n\n"+ f"- Team workspace absolute root: `{self._root_dir}`\n"+ f"- Internal mount path: `{mount}`\n"+ "- Use the internal mount path only for tool read/write operations.\n"+ "- When telling the user where an artifact was saved, report the real absolute filesystem path under "+ "the team workspace absolute root, not the `.team/...` mount path.\n"+ "- If a generated artifact path contains `.team/<team>/team-workspace/`, remove that mount prefix and "+ "join the remaining file name under the team workspace absolute root before reporting it.\n"+ f"- Example saved location to report: `{sample}`\n"+ )+ self.system_prompt_builder.add_section(+ PromptSection(+ name="team_workspace_report_paths",+ content={"cn": content, "en": content},+ priority=67,+ )+ )diff --git a/jiuwenclaw/agentserver/team/team_manager.py b/jiuwenclaw/agentserver/team/team_manager.pyindex 09f8334940..9927c823bb 100644--- a/jiuwenclaw/agentserver/team/team_manager.py+++ b/jiuwenclaw/agentserver/team/team_manager.py@@ -598,6 +598,7 @@ class TeamManager:),runtime=RuntimeInfo(channel=resolved_channel),team_workspace=TeamWorkspaceInfo(+ root_dir=str(Path(team_ws_root)),skills_dir=str(team_ws_skills_dir),trajectories_dir=str(team_ws_trajectories_dir),team_id=spec.team_name,diff --git a/jiuwenclaw/agentserver/team/team_runtime_inheritance.py b/jiuwenclaw/agentserver/team/team_runtime_inheritance.pyindex a218d0c916..8f298d6fb8 100644--- a/jiuwenclaw/agentserver/team/team_runtime_inheritance.py+++ b/jiuwenclaw/agentserver/team/team_runtime_inheritance.py@@ -29,6 +29,7 @@ from jiuwenclaw.agentserver.deep_agent.rails.avatar_rail import AvatarPromptRailfrom jiuwenclaw.agentserver.deep_agent.rails.response_prompt_rail import ResponsePromptRailfrom jiuwenclaw.agentserver.deep_agent.rails.runtime_prompt_rail import RuntimePromptRailfrom jiuwenclaw.agentserver.deep_agent.rails.stream_event_rail import JiuClawStreamEventRail+from jiuwenclaw.agentserver.team.rails import TeamWorkspaceReportPathRaillogger = logging.getLogger(__name__)@@ -51,6 +52,7 @@ class RuntimeInfo:@dataclassclass TeamWorkspaceInfo:"""Team 共享 workspace 信息."""+ root_dir: str | None = Noneskills_dir: str | None = Nonetrajectories_dir: str | None = Noneteam_id: str | None = None@@ -69,6 +71,7 @@ RAIL_WHITELIST = frozenset({"TeamSkillRail","TeamSkillCreateRail","SkillEvolutionRail",+ "TeamWorkspaceReportPathRail",})TOOL_WHITELIST = frozenset({@@ -138,6 +141,7 @@ def build_member_rails(role = member_info.rolechannel = runtime.channellanguage = runtime.language+ team_ws_root = team_workspace.root_dirteam_ws_skills_dir = team_workspace.skills_dirteam_trajectories_dir = team_workspace.trajectories_dirteam_id = team_workspace.team_id@@ -218,6 +222,21 @@ def build_member_rails(except Exception as exc:logger.warning("[TeamRuntime] AvatarPromptRail failed: %s", exc)+ if team_ws_root:+ try:+ rail = TeamWorkspaceReportPathRail(+ root_dir=team_ws_root,+ team_id=team_id,+ language=language,+ )+ rails_list.append(rail)+ logger.info(+ "[TeamRuntime] TeamWorkspaceReportPathRail created: root_dir=%s",+ team_ws_root,+ )+ except Exception as exc:+ logger.warning("[TeamRuntime] TeamWorkspaceReportPathRail failed: %s", exc)+# Leader-only: TeamSkillRail for team skill evolution.if role == "leader" and team_ws_skills_dir:try:diff --git a/tests/unit_tests/agentserver/test_team_runtime_inheritance.py b/tests/unit_tests/agentserver/test_team_runtime_inheritance.pyindex eaffb7894d..207fde3814 100644--- a/tests/unit_tests/agentserver/test_team_runtime_inheritance.py+++ b/tests/unit_tests/agentserver/test_team_runtime_inheritance.py@@ -7,6 +7,7 @@ from unittest.mock import patchfrom openjiuwen.core.foundation.tool import ToolCard+from jiuwenclaw.agentserver.team.rails import TeamWorkspaceReportPathRailfrom jiuwenclaw.agentserver.team.team_runtime_inheritance import (TeamWorkspaceInfo,build_evolution_llm,@@ -178,6 +179,7 @@ def test_build_member_rails_accepts_team_workspace_info(tmp_path):member_info=SimpleNamespace(agent_name="leader", model_name="demo-model", role="leader"),runtime=SimpleNamespace(channel="web", language="cn"),team_workspace=TeamWorkspaceInfo(+ root_dir=str(tmp_path / "team-workspace"),skills_dir=team_workspace.skills_dir,trajectories_dir=team_workspace.trajectories_dir,team_id=team_workspace.team_id,@@ -186,35 +188,3 @@ def test_build_member_rails_accepts_team_workspace_info(tmp_path):)assert isinstance(rails, list)---def test_build_member_rails_uses_shared_skills_dir_for_member_evolution(tmp_path):- captured: dict[str, object] = {}-- def _fake_build_skill_evolution_rail(*, skills_dir, config, team_trajectory_store):- captured["skills_dir"] = skills_dir- captured["config"] = config- captured["team_trajectory_store"] = team_trajectory_store- return object()-- with patch(- "jiuwenclaw.agentserver.team.team_runtime_inheritance.FileTrajectoryStore",- return_value=object(),- ), patch(- "jiuwenclaw.agentserver.team.team_runtime_inheritance.build_skill_evolution_rail",- side_effect=_fake_build_skill_evolution_rail,- ):- build_member_rails(- member_info=SimpleNamespace(agent_name="member", model_name="demo-model", role="member"),- runtime=SimpleNamespace(channel="web", language="cn"),- team_workspace=TeamWorkspaceInfo(- skills_dir=str(tmp_path / "team-shared-skills"),- trajectories_dir=str(tmp_path / "trajectories"),- team_id="demo-team",- config={"evolution": {"auto_scan": False}},- ),- )-- assert captured["skills_dir"] == str(tmp_path / "team-shared-skills")- assert captured["config"] == {"evolution": {"auto_scan": False}}- assert captured["team_trajectory_store"] is not None