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
feat: English language support for tool messages, todo system, and ask_user rail
ldstyle8233c6a1014c5
diff --git a/jiuwenswarm/agents/harness/common/rails/ask_user_rail.py b/jiuwenswarm/agents/harness/common/rails/ask_user_rail.pyindex 431a07d4d0..9a0bac52c8 100644--- a/jiuwenswarm/agents/harness/common/rails/ask_user_rail.py+++ b/jiuwenswarm/agents/harness/common/rails/ask_user_rail.py@@ -209,13 +209,15 @@ class StructuredAskUserRail(AskUserRail):def __init__(self,tool_names: Optional[Iterable[str]] = None,+ language: Optional[str] = None,):super().__init__(tool_names=tool_names)self._structured_tools: list[StructuredAskUserTool] = []+ self._language = languagedef init(self, agent):"""Register the extended ask_user tool with structured questions schema."""- language = resolve_language()+ language = self._language or resolve_language()agent_id = getattr(getattr(agent, "card", None), "id", None)tool = StructuredAskUserTool(language=language, agent_id=agent_id)self._structured_tools = [tool]diff --git a/jiuwenswarm/agents/harness/common/rails/stream_event_rail.py b/jiuwenswarm/agents/harness/common/rails/stream_event_rail.pyindex a51cf5d424..cb4b4d5d93 100644--- a/jiuwenswarm/agents/harness/common/rails/stream_event_rail.py+++ b/jiuwenswarm/agents/harness/common/rails/stream_event_rail.py@@ -213,6 +213,19 @@ class JiuClawStreamEventRail(DeepAgentRail):def init(self, agent: Any) -> None:self._deep_agent = agent+ def _get_prompt_language(self) -> str:+ """Get the current prompt language from the agent's system_prompt_builder."""+ return getattr(+ getattr(self._deep_agent, "system_prompt_builder", None),+ "language", None,+ ) or "cn"++ def _tool_interrupted_message(self, tool_name: str) -> str:+ """Build a language-aware tool interruption message."""+ if self._get_prompt_language() == "en":+ return f"[Tool interrupted] Tool {tool_name} was interrupted by the user and has no result."+ return f"[工具执行被中断] 工具 {tool_name} 执行过程中被用户打断,没有执行结果。"+def _resolve_sid(self, ctx: AgentCallbackContext, session: Session | None = None) -> str:"""Resolve the per-session key used by this rail.@@ -844,7 +857,7 @@ class JiuClawStreamEventRail(DeepAgentRail):await context.add_messages(tool_message_cache[tool_call_id])else:await context.add_messages(ToolMessage(- content=f"[工具执行被中断] 工具 {tool_name} 执行过程中被用户打断,没有执行结果。",+ content=self._tool_interrupted_message(tool_name),tool_call_id=tool_call_id,))tool_id_cache = []@@ -879,7 +892,7 @@ class JiuClawStreamEventRail(DeepAgentRail):await context.add_messages(tool_message_cache[tool_call_id])else:await context.add_messages(ToolMessage(- content=f"[工具执行被中断] 工具 {tool_name} 执行过程中被用户打断,没有执行结果。",+ content=self._tool_interrupted_message(tool_name),tool_call_id=tool_call_id,))tool_id_cache = []@@ -893,7 +906,7 @@ class JiuClawStreamEventRail(DeepAgentRail):await context.add_messages(tool_message_cache[tool_call_id])else:await context.add_messages(ToolMessage(- content=f"[工具执行被中断] 工具 {tool_name} 执行过程中被用户打断,没有执行结果。",+ content=self._tool_interrupted_message(tool_name),tool_call_id=tool_call_id,))except Exception as e:diff --git a/jiuwenswarm/agents/harness/common/tools/user_todo_tool.py b/jiuwenswarm/agents/harness/common/tools/user_todo_tool.pyindex a3a9e1a8ae..f9a0873642 100644--- a/jiuwenswarm/agents/harness/common/tools/user_todo_tool.py+++ b/jiuwenswarm/agents/harness/common/tools/user_todo_tool.py@@ -193,28 +193,32 @@ def _write_todos_file(file_path: str, todos: List[TodoItem]):@tool(name="user_todos",- description="管理用户的个人待办事项和日程安排(如会议、提醒、计划)。当用户提到未来的安排或计划时应主动调用。注意:\- 这是用户的个人待办工具,不要用于 agent 内部的任务规划(内部任务规划请用 todo_create/todo_insert 等工具)。",+ description=(+ "Manage the user's personal todo items and schedule (meetings, reminders, plans). "+ "Proactively invoke when the user mentions future arrangements or plans. "+ "NOTE: This is the user's personal todo tool — do NOT use it for internal agent "+ "task planning (use todo_create/todo_insert for internal task tracking)."+ ),)async def user_todos(params: UserTodosParams) -> Dict[str, Any]:- """管理用户的待办事项列表。支持按 channel 隔离,每个 channel 有独立的待办列表。+ """Manage the user's per-channel todo list. Each channel has an isolated todo list.Args:- params: 待办事项操作参数,包含以下字段:- - action: 操作类型,可选值: list, get, create, update, delete, search- - channel_id: Channel ID,用于隔离不同 channel 的待办事项(默认使用全局 channel_id)- - todo_id: 待办事项 ID(用于 get, update, delete 操作)- - title: 待办事项标题(用于 create, update 操作)- - status: 状态 (pending, in_progress, completed, cancelled)- - priority: 优先级 (high, medium, low)- - due_at: 截止时间 (ISO 格式)- - remind_at: 提醒时间 (ISO 格式)- - created_by: 创建者- - description: 详细描述- - query: 搜索关键词(用于 search 操作)+ params: Todo operation parameters:+ - action: Operation type, one of: list, get, create, update, delete, search+ - channel_id: Channel ID for per-channel isolation (defaults to global channel_id)+ - todo_id: Todo item ID (for get, update, delete)+ - title: Todo title (for create, update)+ - status: Status (pending, in_progress, completed, cancelled)+ - priority: Priority (high, medium, low)+ - due_at: Due time (ISO format)+ - remind_at: Reminder time (ISO format)+ - created_by: Creator+ - description: Detailed description+ - query: Search keyword (for search action)Returns:- 操作结果字典+ Operation result dict"""if isinstance(params, dict):params = UserTodosParams(**{k: v for k, v in params.items() if k in UserTodosParams.__dataclass_fields__})@@ -292,7 +296,7 @@ async def _handle_user_todos(params: UserTodosParams) -> Dict[str, Any]:return {"success": True,"todo": new_todo.to_dict(),- "message": f"待办事项已创建: {params.title}",+ "message": f"Todo created: {params.title}",}elif params.action == "update":@@ -329,7 +333,7 @@ async def _handle_user_todos(params: UserTodosParams) -> Dict[str, Any]:return {"success": True,"todo": todo.to_dict(),- "message": f"待办事项已更新: {todo.title}",+ "message": f"Todo updated: {todo.title}",}elif params.action == "delete":@@ -349,7 +353,7 @@ async def _handle_user_todos(params: UserTodosParams) -> Dict[str, Any]:return {"success": True,- "message": f"待办事项已删除: {todo.title}",+ "message": f"Todo deleted: {todo.title}",}elif params.action == "search":diff --git a/jiuwenswarm/server/runtime/agent_adapter/interface_code.py b/jiuwenswarm/server/runtime/agent_adapter/interface_code.pyindex 5b89c6d419..608d0b5a2b 100644--- a/jiuwenswarm/server/runtime/agent_adapter/interface_code.py+++ b/jiuwenswarm/server/runtime/agent_adapter/interface_code.py@@ -485,7 +485,7 @@ class JiuwenClawCodeAdapter(JiuWenClawDeepAdapter):def _build_structured_ask_user_rail(self) -> StructuredAskUserRail | None:"""构建 StructuredAskUserRail."""try:- return StructuredAskUserRail()+ return StructuredAskUserRail(language=self._resolve_runtime_language())except Exception as exc:logger.warning("[JiuwenClawCodeAdapter] StructuredAskUserRail create failed: %s", exc)return None