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): PPT产物未成功交付时收尾文案中立化,禁止谎报"文件已发送"
CodehubTTGb172015e0e80
diff --git a/jiuwenswarm/server/runtime/skill_turbo/skill_turbo_tools.py b/jiuwenswarm/server/runtime/skill_turbo/skill_turbo_tools.pyindex da9832edad..43e1b658cc 100644--- a/jiuwenswarm/server/runtime/skill_turbo/skill_turbo_tools.py+++ b/jiuwenswarm/server/runtime/skill_turbo/skill_turbo_tools.py@@ -24,14 +24,16 @@ if TYPE_CHECKING:logger = logging.getLogger(__name__)-# ── 停止提示:追加到工具返回值,引导 LLM 总结并结束 ──-_SKILL_TURBO_STOP_HINT = (- "\n\n[SYSTEM] The skill_acceleration_exec task is complete and the artifact has already been "- "generated. The file(s) have ALREADY been sent to the user by the internal "- "delivery pipeline - do NOT call send_file_to_user again. You should now "- "summarize this result to the user and finish your turn. Do NOT call "- "skill_acceleration_exec, skill_tool, or send_file_to_user again for this task - the "- "work is already done; calling any of them again would duplicate the work."+# 中立收尾+_SKILL_TURBO_STOP_HINT_NEUTRAL = (+ "\n\n[SYSTEM] The skill_acceleration_exec task has finished, but the internal "+ "delivery pipeline did NOT confirm that the file(s) were generated and sent "+ "to the user. You should now summarize this result to the user HONESTLY "+ "based on the artifact summary above: clearly state which parts are "+ "incomplete or failed and that the file has NOT been delivered. Do NOT "+ "claim the file was sent. Do NOT call skill_acceleration_exec or skill_tool "+ "again for this task unless the user asks for a retry. Do NOT call "+ "send_file_to_user either; file delivery is handled by the internal pipeline.")_PPT_DELIVERY_SUMMARY_POST_TOOL_HINT = (@@ -42,7 +44,11 @@ _PPT_DELIVERY_SUMMARY_POST_TOOL_HINT = (# HITL 续跑没有外层 tool_result / DeliverySummaryRail;可见终稿用骨架或安全短句,# 禁止把产物摘要账本发给用户。-PPT_TURBO_SAFE_DELIVERY_SUMMARY = "PPT 已生成并交付。"+# HITL 续跑无 P10 骨架(交付未确认)时的用户可见终稿。+PPT_TURBO_UNCONFIRMED_FINISH_TEXT = (+ "PPT 任务已结束,但未能确认文件已生成并发送,部分环节可能未完成。"+ "请查看上方过程信息,或让我重试补齐。"+)_SKILL_TURBO_ARTIFACT_SUMMARY_MARKER = "[SkillAccelerationExec 产物摘要]"# 工具返回值会先被 AbilityManager 收成 ToolMessage。after_tool_call 再用@@ -425,7 +431,7 @@ def visible_ppt_turbo_finish_text() -> str:"""HITL 续跑的用户可见终稿(无外层 skill_acceleration_exec 工具循环)。- 成功时优先发 P10 已填好的交付骨架;没有骨架则用安全短句。+ 成功时优先发 P10 已填好的交付骨架;没有骨架则用交付未确认的中立短句。失败只回可读错误。产物账本不得出现在返回值里。"""from jiuwenswarm.server.runtime.skill_turbo.skill_codes.ppt.delivery_summary import (@@ -436,7 +442,7 @@ def visible_ppt_turbo_finish_text(skeleton = _ppt_delivery_summary(holder)if skeleton.startswith(DELIVERY_SUMMARY_START):return skeleton- return PPT_TURBO_SAFE_DELIVERY_SUMMARY+ return PPT_TURBO_UNCONFIRMED_FINISH_TEXTtext = str(detail or "").strip() or "任务未完成"if _SKILL_TURBO_ARTIFACT_SUMMARY_MARKER in text:return "任务未完成"@@ -465,7 +471,8 @@ def _wrap_skill_turbo_result(parts.append(_PPT_DELIVERY_SUMMARY_POST_TOOL_HINT)else:clear_pending_ppt_delivery_summary()- parts.append(_SKILL_TURBO_STOP_HINT)+ # 无 P10 骨架 = 交付未确认,不宣称文件已发送。+ parts.append(_SKILL_TURBO_STOP_HINT_NEUTRAL)result_dict["result"] = "\n\n".join(p for p in parts if p)else:clear_pending_ppt_delivery_summary()diff --git a/tests/unit_tests/agentserver/test_skill_turbo_hitl_resume_react.py b/tests/unit_tests/agentserver/test_skill_turbo_hitl_resume_react.pyindex bee7468958..d907f091ee 100644--- a/tests/unit_tests/agentserver/test_skill_turbo_hitl_resume_react.py+++ b/tests/unit_tests/agentserver/test_skill_turbo_hitl_resume_react.py@@ -26,7 +26,7 @@ from jiuwenswarm.server.runtime.skill_turbo.permission_bridge import ()from jiuwenswarm.server.runtime.skill_turbo.skill_turbo_tools import (_SKILL_TURBO_HITL_PLACEHOLDER,- _SKILL_TURBO_STOP_HINT,+ _SKILL_TURBO_STOP_HINT_NEUTRAL,_resolve_skill_turbo_resume_session_id,_resume_user_input_from_raw,get_skill_turbo_resume_answers,@@ -35,6 +35,18 @@ from jiuwenswarm.server.runtime.skill_turbo.skill_turbo_tools import (set_skill_turbo_resume_answers,)+# 旧版停止提示文案(宣称文件已发送),生产代码已删除常量;保留字符串仅用于+# 验证存量会话历史(tool_result 嵌旧文案)重放时被 _fix_incomplete_tool_context+# 原样保留——该修复逻辑按 tool_call_id 结构匹配,不依赖常量存在。+_LEGACY_STOP_HINT_TEXT = (+ "\n\n[SYSTEM] The skill_acceleration_exec task is complete and the artifact has already been "+ "generated. The file(s) have ALREADY been sent to the user by the internal "+ "delivery pipeline - do NOT call send_file_to_user again. You should now "+ "summarize this result to the user and finish your turn. Do NOT call "+ "skill_acceleration_exec, skill_tool, or send_file_to_user again for this task - the "+ "work is already done; calling any of them again would duplicate the work."+)+class _StreamSession:def __init__(self):@@ -617,7 +629,7 @@ async def test_fix_incomplete_tool_context_keeps_stop_hint_over_hitl_placeholderrail = JiuSwarmStreamEventRail()tool_call_id = "call_982c"stop_hint_msg = ToolMessage(- content="任务已完成" + _SKILL_TURBO_STOP_HINT,+ content="任务已完成" + _LEGACY_STOP_HINT_TEXT,tool_call_id=tool_call_id,)ctx = SimpleNamespace(@@ -659,3 +671,49 @@ async def test_fix_incomplete_tool_context_keeps_stop_hint_over_hitl_placeholderassert _SKILL_TURBO_HITL_PLACEHOLDER not in tool_msgs[0].contentassert "The skill_acceleration_exec task is complete" in tool_msgs[0].contentassert "skill_tool" in tool_msgs[0].content+++async def test_fix_incomplete_tool_context_keeps_neutral_stop_hint_over_hitl_placeholder():+ # 新版中立收尾与旧版停止提示走同一保留路径:+ # 中断 placeholder 被真实 tool_result(含中立收尾)原位替换。+ rail = JiuSwarmStreamEventRail()+ tool_call_id = "call_982d"+ neutral_msg = ToolMessage(+ content="任务已完成" + _SKILL_TURBO_STOP_HINT_NEUTRAL,+ tool_call_id=tool_call_id,+ )+ ctx = SimpleNamespace(+ context=_ModelContext([+ UserMessage(content="生成一页PPT"),+ AssistantMessage(+ content="",+ tool_calls=[{+ "type": "function",+ "id": tool_call_id,+ "function": {+ "name": "skill_acceleration_exec",+ "arguments": "{\"query\":\"生成PPT\"}",+ },+ }],+ ),+ ToolMessage(+ content=_SKILL_TURBO_HITL_PLACEHOLDER,+ tool_call_id=tool_call_id,+ ),+ neutral_msg,+ ]),+ inputs=SimpleNamespace(tools=[]),+ session=None,+ extra={},+ )++ await rail._fix_incomplete_tool_context(ctx)++ messages = ctx.context.get_messages()+ tool_msgs = [m for m in messages if isinstance(m, ToolMessage)]+ assert len(tool_msgs) == 1+ assert tool_msgs[0].tool_call_id == tool_call_id+ assert _SKILL_TURBO_HITL_PLACEHOLDER not in tool_msgs[0].content+ assert "did NOT confirm" in tool_msgs[0].content+ assert "send_file_to_user" in tool_msgs[0].contentdiff --git a/tests/unit_tests/server/runtime/skill_turbo/test_ppt_delivery_summary.py b/tests/unit_tests/server/runtime/skill_turbo/test_ppt_delivery_summary.pyindex 56e45681c6..ef2e206416 100644--- a/tests/unit_tests/server/runtime/skill_turbo/test_ppt_delivery_summary.py+++ b/tests/unit_tests/server/runtime/skill_turbo/test_ppt_delivery_summary.py@@ -14,7 +14,7 @@ from jiuwenswarm.server.runtime.skill_turbo.skill_codes.ppt.delivery_summary imp)from jiuwenswarm.server.runtime.skill_turbo.skill_codes.ppt.ppt_gen_root import PPTGenRootNodefrom jiuwenswarm.server.runtime.skill_turbo.skill_turbo_tools import (- PPT_TURBO_SAFE_DELIVERY_SUMMARY,+ PPT_TURBO_UNCONFIRMED_FINISH_TEXT,_SKILL_TURBO_ARTIFACT_SUMMARY_MARKER,_wrap_skill_turbo_result,clear_pending_ppt_delivery_summary,@@ -327,6 +327,9 @@ def test_wrap_skill_turbo_result_keeps_generic_hint_without_ppt_summary() -> Nonclear_pending_ppt_delivery_summary()wrapped = _wrap_skill_turbo_result({"success": True, "result": "任务已完成"}, {})assert "You should now summarize" in wrapped["result"]+ assert "did NOT confirm" in wrapped["result"]+ assert "ALREADY been sent" not in wrapped["result"]+ assert "send_file_to_user" in wrapped["result"]assert "逐字输出" not in wrapped["result"]assert take_pending_ppt_delivery_summary() == ""@@ -477,12 +480,13 @@ def test_visible_finish_text_prefers_p10_skeleton() -> None:assert "任务已完成" not in text-def test_visible_finish_text_uses_safe_sentence_without_skeleton() -> None:+def test_visible_finish_text_uses_unconfirmed_text_without_skeleton() -> None:text = visible_ppt_turbo_finish_text({"p8_ppt_page_gen": {"info": {"total_pages": 3}}},success=True,)- assert text == PPT_TURBO_SAFE_DELIVERY_SUMMARY+ assert text == PPT_TURBO_UNCONFIRMED_FINISH_TEXT+ assert "已生成并交付" not in textassert _SKILL_TURBO_ARTIFACT_SUMMARY_MARKER not in text