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:解决skillTurbo resume时任务重复显示问题
Chenchong_RD4f8ac6c0cfb9
diff --git a/jiuwenswarm/server/runtime/agent_adapter/interface.py b/jiuwenswarm/server/runtime/agent_adapter/interface.pyindex 8c6d297628..6c237547cc 100644--- a/jiuwenswarm/server/runtime/agent_adapter/interface.py+++ b/jiuwenswarm/server/runtime/agent_adapter/interface.py@@ -2814,12 +2814,22 @@ class JiuWenSwarm:returnasync for chunk in adapter.process_message_stream_impl(request, inputs):_put_count += 1- if _put_count <= 3:- _pl = getattr(chunk, "payload", None) or {}- _et = _pl.get("event_type", "") if isinstance(_pl, dict) else ""+ _pl = getattr(chunk, "payload", None) or {}+ _et = _pl.get("event_type", "") if isinstance(_pl, dict) else ""+ # 前 3 个 chunk 全量打点;task.* 无论序号都打点,便于确认首跑+ # SkillTurbo write_stream 路径是否把任务列表推到外层流。+ if _put_count <= 3 or (+ isinstance(_et, str) and _et.startswith("task.")+ ):+ _n_tasks = 0+ if isinstance(_pl, dict) and isinstance(_pl.get("tasks"), list):+ _n_tasks = len(_pl["tasks"])logger.info(- "[JiuWenSwarm] run_stream_task chunk #%s: request_id=%s event_type=%s",- _put_count, rid, _et,+ "[JiuWenSwarm] run_stream_task chunk #%s: request_id=%s event_type=%s%s",+ _put_count,+ rid,+ _et,+ f" tasks={_n_tasks}" if _n_tasks else "",)await stream_queue.put(("chunk", chunk))except asyncio.CancelledError:diff --git a/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py b/jiuwenswarm/server/runtime/agent_adapter/interface_deep.pyindex 0da4c556da..ad23ee80a5 100644--- a/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py+++ b/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py@@ -9454,6 +9454,7 @@ class JiuWenSwarmDeepAdapter:channel_id=request.channel_id,pending_tool_call_id=resume_ctx["pending_tool_call_id"],user_input=user_input,+ task_states=resume_ctx.get("task_states"),):yield chunkexcept _SkillTurboAbortError as e:diff --git a/jiuwenswarm/server/runtime/skill_turbo/agent.py b/jiuwenswarm/server/runtime/skill_turbo/agent.pyindex 4004b30ebc..5248feaeeb 100644--- a/jiuwenswarm/server/runtime/skill_turbo/agent.py+++ b/jiuwenswarm/server/runtime/skill_turbo/agent.py@@ -105,6 +105,7 @@ class SkillTurbo:channel_id: str,pending_tool_call_id: str,user_input: Any,+ task_states: list[dict[str, Any]] | None = None,) -> AsyncIterator[AgentResponseChunk]:"""从 HITL 中断点恢复执行:跳过 planner,直接重放 plan_code。@@ -112,6 +113,7 @@ class SkillTurbo:- 中断时保存的 ``plan_code`` / ``inputs``- 中断时记录的 ``pending_tool_call_id``- 用户审批回复(``ConfirmPayload`` / dict / etc.)+ - 可选 ``task_states``:中断时任务快照,resume 复用同一套 ``task_id``二次执行时 ``SkillTurboExecutor`` 重放到同一 tool_call_id,将 ``user_input``注入 ctx.extra[RESUME_USER_INPUT_KEY],``PermissionInterruptRail`` 据此@@ -120,6 +122,7 @@ class SkillTurbo:self._executor.set_pending_resume(expected_tool_call_id=pending_tool_call_id,user_input=user_input,+ task_states=task_states,)try:async for chunk in self._executor.execute_plan_stream(diff --git a/jiuwenswarm/server/runtime/skill_turbo/executor.py b/jiuwenswarm/server/runtime/skill_turbo/executor.pyindex 4d98514627..713b9c5d5b 100644--- a/jiuwenswarm/server/runtime/skill_turbo/executor.py+++ b/jiuwenswarm/server/runtime/skill_turbo/executor.py@@ -616,6 +616,10 @@ class SkillTurboExecutor:# ⑥ 预先扫描 root 的子节点,初始化所有任务状态(状态为 pending)await self._initialize_pending_tasks(root)+ # 立即排出初始化快照,避免等首个 node 输出才看到任务列表+ # (首跑经 write_stream 转发时尤其明显;resume 复用同路径)。+ async for task_chunk in self._drain_task_event_chunks():+ yield task_chunk# ⑦ 流式执行规划# 注意:底层 LLM HTTP 调用和工具调用已有各自超时,上层暂不加整体超时@@ -1246,6 +1250,7 @@ class SkillTurboExecutor:*,expected_tool_call_id: str,user_input: Any,+ task_states: list[dict[str, Any]] | None = None,) -> None:"""adapter 在 resume 路径开始执行前调用,注入用户审批回复。@@ -1253,22 +1258,47 @@ class SkillTurboExecutor:将一次性把 ``user_input`` 注入 ctx.extra[RESUME_USER_INPUT_KEY],让 ``PermissionInterruptRail`` 完成 approve / reject 决策。其它 tool_call 不带 resume 输入(首次行为)。++ ``task_states``:中断时保存的任务快照;``_initialize_pending_tasks`` 会+ 一次性取出并复用其中的 ``task_id``(不消费 ``user_input``)。"""if not expected_tool_call_id:returnself._pending_resume = {"expected_tool_call_id": expected_tool_call_id,"user_input": user_input,+ "task_states": copy.deepcopy(task_states) if task_states else None,}+ def _take_resume_task_states(self) -> list[dict[str, Any]] | None:+ """从 pending_resume 取出任务快照(只取一次,不影响 user_input 消费)。"""+ pending = self._pending_resume+ if not pending:+ return None+ states = pending.pop("task_states", None)+ if not isinstance(states, list) or not states:+ return None+ return states++ def _snapshot_task_states(self) -> list[dict[str, Any]]:+ """中断时导出当前二层任务快照,供 resume_ctx 持久化。"""+ if self._task_states_holder:+ return [copy.deepcopy(state) for state in self._task_states_holder.values()]+ task_states = _task_states_var.get()+ if task_states:+ return [copy.deepcopy(state) for state in task_states.values()]+ return []+def _consume_pending_resume_input(self, current_tool_call_id: str) -> Any | None:pending = self._pending_resumeif not pending:return Noneif pending.get("expected_tool_call_id") != current_tool_call_id:return None+ user_input = pending.get("user_input")+ # 保留可能尚未取出的 task_states(理论上 init 已 pop);整表清空self._pending_resume = None- return pending.get("user_input")+ return user_inputdef _next_tool_call_id(self, tool_name: str, kwargs: dict[str, Any]) -> str:"""生成确定性 tool_call_id:基于 (tool_name, canonical_args, call_index) 哈希。@@ -1451,6 +1481,7 @@ class SkillTurboExecutor:plan_code=self._current_plan_code,inputs=self._execution_inputs,pending_tool_call_id=tool_call_id,+ task_states=self._snapshot_task_states(),)logger.info("[SkillTurboExecutor] HITL interrupt resume_ctx saved tcid=%s",@@ -2032,11 +2063,14 @@ class SkillTurboExecutor:# HITL 中断(PermissionInterruptRail.AbortError)必须向上抛,# 不能转成 node_error_chunk —— 否则 SkillTurbo.run_stream 看不到中断,# adapter 也就拿不到 AbortError 来发 HITL 三件套。+ # 先排空已入队的 task.*,避免中断瞬间丢最新任务快照。if isinstance(item, AbortError) or extract_tool_interrupt(item) is not None:logger.info("[SkillTurboExecutor] _execute_node_stream propagate HITL AbortError: %s",item,)+ async for task_chunk in self._drain_task_event_chunks():+ yield task_chunkraise itemlogger.error("[SkillTurboExecutor] _execute_node_stream error: %s", item)async for task_chunk in self._drain_task_event_chunks():@@ -2370,7 +2404,12 @@ class SkillTurboExecutor:payload["event_type"] = "task.complete" if "status" in payload else "task.start"async def _initialize_pending_tasks(self, root: PlanNode) -> None:- """预置二层任务列表,让前端在第一个 task.start 前就能展示完整待办。"""+ """预置二层任务列表,让前端在第一个 task.start 前就能展示完整待办。++ 首次执行:为每个 sub_plan 分配新 ``task_id``。+ HITL resume:复用 ``resume_ctx.task_states`` 中的 ``task_id`` / 状态,+ 避免前端 taskRuns 因新 UUID 叠出第二套 Stage。+ """task_states = _task_states_var.get()if task_states is None or not getattr(root, "sub_plans", None):return@@ -2379,6 +2418,19 @@ class SkillTurboExecutor:self._task_states_holder.clear()self._current_task_id_holder["task_id"] = None+ saved = self._take_resume_task_states()+ if saved is not None:+ restored = self._restore_task_states_from_snapshot(root, saved)+ for task_id, task_state in restored.items():+ task_states[task_id] = task_state+ self._task_states_holder[task_id] = task_state+ await self._emit_task_update_event()+ logger.info(+ "[SkillTurboExecutor] execute_plan_stream restored %d tasks from resume snapshot",+ len(task_states),+ )+ return+for idx, subplan in enumerate(root.sub_plans):task_id = f"task_{uuid.uuid4().hex[:8]}"task_state = {@@ -2398,28 +2450,93 @@ class SkillTurboExecutor:len(task_states),)- @staticmethod- async def _emit_task_update_event() -> None:- """发送 task.update 事件(全量任务状态快照)。"""- task_states = _task_states_var.get()+ def _restore_task_states_from_snapshot(+ self,+ root: PlanNode,+ saved: list[dict[str, Any]],+ ) -> dict[str, dict[str, Any]]:+ """按 display name / index 对齐 resume 快照,复用原 ``task_id``。"""+ by_content: dict[str, dict[str, Any]] = {}+ by_index: dict[int, dict[str, Any]] = {}+ for item in saved:+ if not isinstance(item, dict):+ continue+ content = item.get("task_content")+ if isinstance(content, str) and content.strip():+ by_content[content] = item+ idx = item.get("task_index")+ if isinstance(idx, int):+ by_index[idx] = item++ restored: dict[str, dict[str, Any]] = {}+ used_ids: set[str] = set()+ for idx, subplan in enumerate(root.sub_plans):+ display = self._display_name(subplan.plan_name)+ snap = by_content.get(display) or by_index.get(idx)+ task_id: str | None = None+ if snap is not None:+ raw_id = snap.get("task_id")+ if isinstance(raw_id, str) and raw_id.strip() and raw_id not in used_ids:+ task_id = raw_id.strip()++ if task_id is not None and snap is not None:+ state = copy.deepcopy(snap)+ state["task_id"] = task_id+ state["task_content"] = display+ state["task_index"] = idx+ state.setdefault("source", "skill_turbo")+ if not isinstance(state.get("status"), str):+ state["status"] = "pending"+ used_ids.add(task_id)+ else:+ task_id = f"task_{uuid.uuid4().hex[:8]}"+ state = {+ "task_id": task_id,+ "task_content": display,+ "task_index": idx,+ "source": "skill_turbo",+ "status": "pending",+ }+ restored[task_id] = state+ return restored++ def _live_task_states(self) -> dict[str, dict[str, Any]] | None:+ """运行中任务表:优先实例 holder(跨 create_task 共享),再回退 ContextVar。"""+ if self._task_states_holder:+ return self._task_states_holder+ return _task_states_var.get()++ async def _emit_task_update_event(self) -> None:+ """发送 task.update 事件(全量任务状态快照)。++ 优先读 ``_task_states_holder``:``asyncio.create_task`` 会复制 ContextVar,+ 仅依赖 ``_task_states_var`` 可能读到空/旧 dict,把错误的 pending 快照推给前端。+ """events_queue = _task_events_queue_var.get()-+ task_states = self._live_task_states()+if task_states is None or events_queue is None:logger.debug("[SkillTurboExecutor] _emit_task_update_event skip: no task_states or events_queue")return-- # 深拷贝任务状态(避免后续修改影响已发送的事件)- all_tasks = [copy.deepcopy(state) for state in task_states.values()]-++ # 深拷贝任务状态(避免后续修改影响已发送的事件);按 index 排序保证前端稳定+ all_tasks = sorted(+ (copy.deepcopy(state) for state in task_states.values()),+ key=lambda t: (+ t.get("task_index") if isinstance(t.get("task_index"), int) else 10**9,+ str(t.get("task_id") or ""),+ ),+ )+# 计算统计信息total = len(all_tasks)completed = sum(1 for t in all_tasks if t.get("status") == "completed")in_progress = sum(1 for t in all_tasks if t.get("status") == "in_progress")pending = sum(1 for t in all_tasks if t.get("status") == "pending")failed = sum(1 for t in all_tasks if t.get("status") == "failed")-+# 构建 payloadpayload = {"event_type": "task.update",@@ -2432,12 +2549,22 @@ class SkillTurboExecutor:"parent_request_id": _request_id_var.get(),"timestamp": time.time(),}-- logger.debug(- "[SkillTurboExecutor] task.update: %d tasks - %d completed, %d in_progress, %d pending, %d failed",- total, completed, in_progress, pending, failed++ status_preview = [+ f"{t.get('task_index')}:{t.get('status')}"+ for t in all_tasks[:8]+ ]+ logger.info(+ "[SkillTurboExecutor] task.update: %d tasks - "+ "%d completed, %d in_progress, %d pending, %d failed; preview=%s",+ total,+ completed,+ in_progress,+ pending,+ failed,+ status_preview,)-+# 添加到事件队列task_update_event = {"request_id": _request_id_var.get(),@@ -2473,7 +2600,7 @@ class SkillTurboExecutor:)events_queue = _task_events_queue_var.get()- task_states = _task_states_var.get()+ task_states = self._live_task_states()if events_queue is None or task_states is None:logger.debug(@@ -2484,6 +2611,22 @@ class SkillTurboExecutor:task_id, task_state = self._get_or_create_task_state(subplan, task_states)timestamp = time.time()self._set_current_task_context(subplan, task_id, timestamp)++ # HITL resume 会从根节点重放 plan。已 completed 的 stage 若再标成+ # in_progress,会与快照里仍 in_progress 的中断 stage 同时“运行”。+ if task_state.get("status") == "completed":+ logger.info(+ "[SkillTurboExecutor] skip task.start for already-completed stage "+ "(resume replay): task_id=%s plan_name=%s",+ task_id,+ subplan.plan_name,+ )+ return++ # 兜底:启动较早 stage 时,把更靠后仍 in_progress 的 stage 收成 pending,+ # 保证右侧任务列表同一时刻只有一个 running。+ self._park_later_in_progress_tasks(task_state, task_states)+self._update_task_state_on_start(task_state, timestamp)logger.debug(@@ -2529,7 +2672,7 @@ class SkillTurboExecutor:task_context = _current_task_context_var.get()events_queue = _task_events_queue_var.get()- task_states = _task_states_var.get()+ task_states = self._live_task_states()if events_queue is None or task_context is None or task_states is None:logger.debug(@@ -2542,6 +2685,26 @@ class SkillTurboExecutor:duration_ms = int((timestamp - task_context.get("start_time", time.time())) * 1000)is_error = isinstance(result_or_error, Exception)status = "failed" if is_error else "completed"+ prior_status = (+ task_states[task_id].get("status") if task_id in task_states else None+ )++ # Resume 重放已完成 stage:before 已跳过 start,这里也跳过 complete/UI,+ # 仍收集产物并清理 context。+ if prior_status == "completed" and not is_error:+ logger.info(+ "[SkillTurboExecutor] skip task.complete for already-completed stage "+ "(resume replay): task_id=%s plan_name=%s",+ task_id,+ subplan.plan_name,+ )+ _current_task_context_var.set(None)+ self._current_task_id_holder["task_id"] = None+ current_task_holder = _current_task_holder_var.get()+ if current_task_holder is not None:+ current_task_holder["task_id"] = None+ self._collect_node_artifact(subplan, result_or_error, task_id, timestamp, is_error)+ returnlogger.debug("[SkillTurboExecutor] task.complete: task_id=%s task_name=%s status=%s duration_ms=%d depth=%d",@@ -2689,6 +2852,25 @@ class SkillTurboExecutor:if current_task_holder is not None:current_task_holder["task_id"] = task_id+ @staticmethod+ def _park_later_in_progress_tasks(+ current: dict[str, Any],+ task_states: dict[str, dict[str, Any]],+ ) -> None:+ """把 index 更大且仍 in_progress 的 stage 收成 pending。"""+ cur_idx = current.get("task_index")+ if not isinstance(cur_idx, int):+ return+ for other in task_states.values():+ if other is current:+ continue+ if other.get("status") != "in_progress":+ continue+ other_idx = other.get("task_index")+ if isinstance(other_idx, int) and other_idx > cur_idx:+ other["status"] = "pending"+ other.pop("start_time", None)+@staticmethoddef _update_task_state_on_start(task_state: dict[str, Any],diff --git a/jiuwenswarm/server/runtime/skill_turbo/permission_bridge.py b/jiuwenswarm/server/runtime/skill_turbo/permission_bridge.pyindex 5d9161bada..1fcc2d5301 100644--- a/jiuwenswarm/server/runtime/skill_turbo/permission_bridge.py+++ b/jiuwenswarm/server/runtime/skill_turbo/permission_bridge.py@@ -234,21 +234,27 @@ async def save_resume_ctx(plan_code: str,inputs: dict[str, Any],pending_tool_call_id: str,+ task_states: list[dict[str, Any]] | None = None,) -> None:"""中断时保存断点上下文到 session state(checkpointer 持久化)。调用方应已 pre_run(executor 在 _persist_node_artifacts 中 pre_run 过),本函数负责 update_state + post_run 完成落盘(与 node_artifacts 共一次 post_run)。++ ``task_states``:中断时的二层任务全量快照(含稳定 ``task_id``)。+ resume 时复用同一套 id,避免前端 taskRuns 因新 UUID 叠出两套 Stage。"""if session is None:logger.warning("[SkillTurboResume] save_resume_ctx: session is None, skipping")returnsid = _get_sid(session)- entry = {+ entry: dict[str, Any] = {"plan_code": plan_code,"inputs": dict(inputs),"pending_tool_call_id": pending_tool_call_id,}+ if task_states:+ entry["task_states"] = copy.deepcopy(task_states)# 与 save_node_artifacts 一致:pre_run 后 update_state 才能经 checkpointer 持久化。# 调用方若已在 pre_run 上下文里,重复 pre_run 是 no-op。try:@@ -265,8 +271,11 @@ async def save_resume_ctx()raiselogger.info(- "[SkillTurboResume] save_resume_ctx: sid=%s tcid=%s plan_code_len=%d",- sid, pending_tool_call_id, len(plan_code or ""),+ "[SkillTurboResume] save_resume_ctx: sid=%s tcid=%s plan_code_len=%d task_states=%d",+ sid,+ pending_tool_call_id,+ len(plan_code or ""),+ len(entry.get("task_states") or []),)try:await session.post_run()diff --git a/jiuwenswarm/server/runtime/skill_turbo/skill_codes/ppt/pipeline_init.py b/jiuwenswarm/server/runtime/skill_turbo/skill_codes/ppt/pipeline_init.pyindex c59af96a86..f172916083 100644--- a/jiuwenswarm/server/runtime/skill_turbo/skill_codes/ppt/pipeline_init.py+++ b/jiuwenswarm/server/runtime/skill_turbo/skill_codes/ppt/pipeline_init.py@@ -173,6 +173,36 @@ def _parse_cli_path(output: str) -> str:raise PipelineInitError(f"无法从命令输出解析路径:\n{output}")+def _normalize_ppt_session_parent(path: Path) -> Path:+ """PPT 时间戳目录的父路径:智能体工作空间本身,不再套一层 workspace。++ 智能体工作空间是 ``.../agent/workspace``(部分环境为 ``.../agent/jiuwenclaw_workspace``)。+ 历史兜底 ``{cwd}/workspace`` 会在工作空间已叫 workspace 时变成+ ``.../agent/workspace/workspace``。+ """+ resolved = path.expanduser()+ try:+ resolved = resolved.resolve()+ except OSError:+ resolved = resolved.absolute()+ agent_names = {"workspace", "jiuwenclaw_workspace"}+ if resolved.name.lower() == "workspace" and resolved.parent.name.lower() in agent_names:+ return resolved.parent+ if resolved.name.lower() == "projects" and resolved.parent.name.lower() in agent_names:+ return resolved.parent+ return resolved+++def _default_ppt_session_parent() -> Path:+ """最后兜底:相对 cwd 的 workspace,经 normalize 避免套一层 workspace。++ 不直接 import ``jiuwenswarm.common.utils``:builtin skill_code 校验只允许+ 安全标准库与 ``skill_turbo`` 内部模块;上游通常已通过 ``workspace_base`` /+ ``effective_project_dir`` 传入正确目录,此处仅作无输入时的兜底。+ """+ return _normalize_ppt_session_parent(Path("workspace"))++def _resolve_explicit_output_dir(inputs: dict[str, Any]) -> str | None:"""上游显式指定的最终产物目录(完整路径,不再追加时间戳)。"""explicit = inputs.get("output_dir")@@ -181,7 +211,7 @@ def _resolve_explicit_output_dir(inputs: dict[str, Any]) -> str | None:text = str(explicit).strip()if not text:return None- return str(Path(text).expanduser().resolve())+ return str(_normalize_ppt_session_parent(Path(text)))def _resolve_timestamp_parent_dir(inputs: dict[str, Any]) -> str:@@ -195,7 +225,7 @@ def _resolve_timestamp_parent_dir(inputs: dict[str, Any]) -> str:# 优先使用显式指定的 workspace_base(通常来自 SkillTurbo 工具传入的 output_dir)workspace_base = inputs.get("workspace_base") or inputs.get("workspace")if workspace_base:- return str(Path(str(workspace_base)).expanduser().resolve())+ return str(_normalize_ppt_session_parent(Path(str(workspace_base))))# fallback:从 effective_project_dir 重建路径project_dir = inputs.get("effective_project_dir")@@ -204,7 +234,9 @@ def _resolve_timestamp_parent_dir(inputs: dict[str, Any]) -> str:user_id = str(inputs.get("user_id") or session)chat_id = str(inputs.get("chat_id") or session)return str(- (Path(str(project_dir)) / "files" / user_id / chat_id / "output").resolve()+ _normalize_ppt_session_parent(+ Path(str(project_dir)) / "files" / user_id / chat_id / "output"+ ))return _resolve_workspace_base(inputs)@@ -212,11 +244,11 @@ def _resolve_timestamp_parent_dir(inputs: dict[str, Any]) -> str:def _resolve_workspace_base(inputs: dict[str, Any]) -> str:workspace_base = inputs.get("workspace_base")if workspace_base:- return str(Path(str(workspace_base)).expanduser().resolve())+ return str(_normalize_ppt_session_parent(Path(str(workspace_base))))workspace = inputs.get("workspace")if workspace:- return str(Path(str(workspace)).expanduser().resolve())- return str(Path("./workspace").expanduser().resolve())+ return str(_normalize_ppt_session_parent(Path(str(workspace))))+ return str(_default_ppt_session_parent())class P01EnvDepsNode(PlanNode):diff --git a/jiuwenswarm/server/runtime/skill_turbo/skill_turbo_tools.py b/jiuwenswarm/server/runtime/skill_turbo/skill_turbo_tools.pyindex b7dbb70c16..757fe94315 100644--- a/jiuwenswarm/server/runtime/skill_turbo/skill_turbo_tools.py+++ b/jiuwenswarm/server/runtime/skill_turbo/skill_turbo_tools.py@@ -277,10 +277,11 @@ async def skill_turbo(query: str) -> dict[str, Any]:outer_task_id = get_current_task_id()has_outer_todo = outer_task_id is not Nonelogger.info(- "[SkillTurboTool] outer todo active=%s outer_task_id=%s, "+ "[SkillTurboTool] outer todo active=%s outer_task_id=%s parent_session=%s, ""task events will be %s",has_outer_todo,outer_task_id,+ type(parent_session).__name__ if parent_session is not None else None,"skipped" if has_outer_todo else "forwarded as-is",)@@ -324,6 +325,16 @@ async def skill_turbo(query: str) -> dict[str, Any]:"[SkillTurboTool] workspace_base 设置为 output_dir: %s",output_dir.strip())+ if "workspace_base" not in inputs:+ try:+ from jiuwenswarm.common.utils import get_agent_workspace_dir++ inputs["workspace_base"] = str(get_agent_workspace_dir())+ except Exception:+ logger.debug(+ "[SkillTurboTool] fallback workspace_base 使用 agent workspace 失败",+ exc_info=True,+ )if isinstance(request_metadata, dict):inputs["metadata"] = request_metadata@@ -365,8 +376,29 @@ async def skill_turbo(query: str) -> dict[str, Any]:)try:await parent_session.write_stream(output)+ if event_type in _SKILL_TURBO_TASK_EVENT_TYPES:+ tasks = chunk.payload.get("tasks") if isinstance(chunk.payload, dict) else None+ n_tasks = len(tasks) if isinstance(tasks, list) else 0+ logger.info(+ "[SkillTurboTool] forwarded %s via write_stream "+ "output_type=%s tasks=%s parent_session=%s",+ event_type,+ output_type,+ n_tasks,+ type(parent_session).__name__,+ )except Exception:- logger.debug("[SkillTurboTool] write_stream failed, skipping", exc_info=True)+ logger.warning(+ "[SkillTurboTool] write_stream failed for event_type=%s",+ event_type,+ exc_info=True,+ )+ elif event_type in _SKILL_TURBO_TASK_EVENT_TYPES:+ logger.warning(+ "[SkillTurboTool] drop %s: parent_session is None "+ "(task list will not reach frontend)",+ event_type,+ )# 过程输出已通过 write_stream 实时推给前端,tool result 仅返回精简完成信号 + 产物摘要return _wrap_skill_turbo_result(