fix(agent): report progress during long tool runs

This commit is contained in:
jxxghp
2026-08-07 06:57:07 +08:00
parent 5654512d41
commit ea8d1f8d26
2 changed files with 25 additions and 6 deletions
+6 -6
View File
@@ -145,12 +145,12 @@ class PromptManager:
if not settings.AI_AGENT_VERBOSE: if not settings.AI_AGENT_VERBOSE:
verbose_spec = ( verbose_spec = (
"\n\n[Important Instruction] STRICTLY ENFORCED: " "\n\n[Important Instruction] STRICTLY ENFORCED: "
"If tools are needed, DO NOT output any conversational text, explanations, progress updates, " "Keep tool-related narration concise and useful. "
"or acknowledgements before the first tool call or between tool calls. " "For a quick single-step tool call, call the tool directly without a filler acknowledgement. "
"Call tools directly without any transitional phrases. " "For multi-step work or any task that may take noticeable time, send one brief user-facing progress update "
"You MUST remain completely silent until all required tools have finished and you have the final result. " "before the first tool call, then another short update after a meaningful milestone or several tool calls. "
"Only then may you send one final user-facing reply. " "State what you are checking or what you learned, without exposing hidden reasoning, raw tool arguments, "
"DO NOT output any intermediate content whatsoever." "or repetitive per-tool narration. Continue working after each update and finish with a concise final result."
) )
# MoviePilot系统信息 # MoviePilot系统信息
+19
View File
@@ -0,0 +1,19 @@
from unittest.mock import patch
from app.agent.prompt import prompt_manager
from app.core.config import settings
from app.schemas.types import MessageChannel
def test_non_verbose_prompt_keeps_long_running_tasks_user_visible() -> None:
"""非详细模式下的长任务仍应主动向用户提供阶段性进度。"""
with patch.object(settings, "AI_AGENT_VERBOSE", False):
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 "Continue working after each update" in prompt
assert "remain completely silent" not in prompt
assert "DO NOT output any intermediate content" not in prompt