From bf98e4c9546ab79f54afd76a382a721dd38113d6 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sat, 6 Jun 2026 07:37:42 +0800 Subject: [PATCH] Ensure batch AI redo returns plain text --- app/agent/prompt/System Tasks.yaml | 2 ++ tests/test_history_batch_ai_redo_prompt.py | 42 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tests/test_history_batch_ai_redo_prompt.py diff --git a/app/agent/prompt/System Tasks.yaml b/app/agent/prompt/System Tasks.yaml index 0625808d..49c1cc7d 100644 --- a/app/agent/prompt/System Tasks.yaml +++ b/app/agent/prompt/System Tasks.yaml @@ -124,6 +124,8 @@ task_types: - "When several records obviously share the same media identity, avoid repeated `recognize_media` or `search_media` calls." - "Process every selected record exactly once." - "Keep the final response short and focused on the aggregate outcome." + - "Final response must be plain text only: one concise Chinese sentence or paragraph describing the aggregate result." + - "Do NOT include any title/header, bullet list, numbered list, bold text, code block, table, or other Markdown formatting." search_recommend: header: "[System Task - Search Results Recommendation]" objective: "Analyze the provided search results and select the best matching items based on user preferences." diff --git a/tests/test_history_batch_ai_redo_prompt.py b/tests/test_history_batch_ai_redo_prompt.py new file mode 100644 index 00000000..171342c0 --- /dev/null +++ b/tests/test_history_batch_ai_redo_prompt.py @@ -0,0 +1,42 @@ +from types import SimpleNamespace + +from app.agent.prompt import prompt_manager +from app.api.endpoints.history import build_batch_manual_redo_prompt + + +def test_batch_manual_redo_prompt_requires_plain_text_result(): + """批量 AI 重新整理提示词应要求最终回复只输出纯文本描述。""" + history = SimpleNamespace( + id=7, + src_fileitem={"path": "/downloads/a.mkv"}, + src="", + seasons="", + episodes="", + status=False, + title="示例", + type="电影", + category="电影", + year="2024", + src_storage="local", + dest="/media/a.mkv", + dest_storage="local", + mode="copy", + tmdbid=123, + doubanid=None, + errmsg="识别失败", + ) + + prompt = build_batch_manual_redo_prompt([history]) + + assert "Final response must be plain text only" in prompt + assert "Do NOT include any title/header, bullet list" in prompt + assert "Markdown formatting" in prompt + + +def test_batch_manual_redo_job_definition_contains_plain_text_rules(): + """批量 AI 重新整理任务定义应直接声明纯文本最终回复规则。""" + definition = prompt_manager.load_system_tasks_definition() + task_rules = definition.task_types["batch_manual_transfer_redo"].task_rules + + assert any("plain text only" in rule for rule in task_rules) + assert any("Markdown formatting" in rule for rule in task_rules)