From b80642f56f0edcbc769851cbe75bd6d8748355f4 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Fri, 7 Aug 2026 07:17:27 +0800 Subject: [PATCH] fix(agent): decouple progress prompt from tool display --- app/agent/prompt/System Core Prompt.txt | 10 +++++++- app/agent/prompt/__init__.py | 18 -------------- tests/test_agent_progress_updates.py | 32 +++++++++++++++---------- 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/app/agent/prompt/System Core Prompt.txt b/app/agent/prompt/System Core Prompt.txt index 2bbd2715..7f1466cd 100644 --- a/app/agent/prompt/System Core Prompt.txt +++ b/app/agent/prompt/System Core Prompt.txt @@ -85,7 +85,15 @@ You act as a proactive agent. Your goal is to fully resolve the user's media-rel -{verbose_spec} + +- Use a concise Codex-style progress cadence. +- For a quick single-step tool call, call the tool directly without a filler acknowledgement. +- For multi-step work or any task that may take noticeable time, send one brief user-facing progress update before the first tool call. +- While work continues, send another update after a meaningful milestone or several tool calls, and approximately every 30 to 60 seconds whenever you regain control. +- Keep each update to one or two short sentences that state what you are doing, what you have learned, and what comes next when those details are useful. +- Vary the wording and do not repeat an unchanged status. Do not expose hidden reasoning, raw tool arguments, or repetitive per-tool narration. +- Continue working after each update. The final reply must be self-contained and summarize the outcome without relying on the user having read the progress updates. + - Channel-aware formatting: Follow the capability rules below for Markdown, plain text, buttons, and voice replies. {button_choice_spec} diff --git a/app/agent/prompt/__init__.py b/app/agent/prompt/__init__.py index 7499f8ce..6b0f0c98 100644 --- a/app/agent/prompt/__init__.py +++ b/app/agent/prompt/__init__.py @@ -140,23 +140,6 @@ class PromptManager: markdown_spec = self._generate_formatting_instructions(caps) button_choice_spec = self._generate_button_choice_instructions(msg_channel) - # 啰嗦模式 - verbose_spec = "" - if not settings.AI_AGENT_VERBOSE: - verbose_spec = ( - "\n\n[Important Instruction] STRICTLY ENFORCED: " - "Use a concise Codex-style progress cadence. " - "For a quick single-step tool call, call the tool directly without a filler acknowledgement. " - "For multi-step work or any task that may take noticeable time, send one brief user-facing progress update " - "before the first tool call. While work continues, send another update after a meaningful milestone or " - "several tool calls, and approximately every 30 to 60 seconds whenever you regain control. " - "Keep each update to one or two short sentences that state what you are doing, what you have learned, " - "and what comes next when those details are useful. Vary the wording and do not repeat an unchanged status. " - "Do not expose hidden reasoning, raw tool arguments, or repetitive per-tool narration. " - "Continue working after each update. The final reply must be self-contained and summarize the outcome " - "without relying on the user having read the progress updates." - ) - # MoviePilot系统信息 moviepilot_info = self._get_moviepilot_info() voice_reply_spec = self._generate_voice_reply_instructions() @@ -164,7 +147,6 @@ class PromptManager: # 始终替换占位符,避免后续 .format() 时因残留花括号报 KeyError base_prompt = base_prompt.format( markdown_spec=markdown_spec, - verbose_spec=verbose_spec, moviepilot_info=moviepilot_info, voice_reply_spec=voice_reply_spec, button_choice_spec=button_choice_spec, diff --git a/tests/test_agent_progress_updates.py b/tests/test_agent_progress_updates.py index 513c224a..4e296d58 100644 --- a/tests/test_agent_progress_updates.py +++ b/tests/test_agent_progress_updates.py @@ -5,19 +5,27 @@ from app.core.config import settings from app.schemas.types import MessageChannel -def test_non_verbose_prompt_keeps_long_running_tasks_user_visible() -> None: - """非详细模式下的长任务仍应主动向用户提供阶段性进度。""" +def test_progress_prompt_is_independent_from_tool_display_mode() -> None: + """进度沟通规则不应随工具逐条或汇总展示模式变化。""" with patch.object(settings, "AI_AGENT_VERBOSE", False): - prompt = prompt_manager.get_agent_prompt( + summary_mode_prompt = prompt_manager.get_agent_prompt( + channel=MessageChannel.WebAgent.value + ) + with patch.object(settings, "AI_AGENT_VERBOSE", True): + verbose_mode_prompt = prompt_manager.get_agent_prompt( channel=MessageChannel.WebAgent.value ) - assert "before the first tool call" in prompt - assert "after a meaningful milestone or several tool calls" in prompt - assert "approximately every 30 to 60 seconds whenever you regain control" in prompt - assert "one or two short sentences" in prompt - assert "do not repeat an unchanged status" in prompt - assert "Continue working after each update" in prompt - assert "The final reply must be self-contained" in prompt - assert "remain completely silent" not in prompt - assert "DO NOT output any intermediate content" not in prompt + assert summary_mode_prompt == verbose_mode_prompt + assert "before the first tool call" in summary_mode_prompt + assert "after a meaningful milestone or several tool calls" in summary_mode_prompt + assert ( + "approximately every 30 to 60 seconds whenever you regain control" + in summary_mode_prompt + ) + assert "one or two short sentences" in summary_mode_prompt + assert "do not repeat an unchanged status" in summary_mode_prompt + assert "Continue working after each update" in summary_mode_prompt + assert "The final reply must be self-contained" in summary_mode_prompt + assert "remain completely silent" not in summary_mode_prompt + assert "DO NOT output any intermediate content" not in summary_mode_prompt