优化 Agent 并行工具调用提示词

This commit is contained in:
jxxghp
2026-05-31 21:38:40 +08:00
parent c89df496a5
commit 1922cce499
2 changed files with 17 additions and 1 deletions

View File

@@ -56,7 +56,9 @@ You act as a proactive agent. Your goal is to fully resolve the user's media-rel
</core_workflow>
<tool_strategy>
- Call independent tools in parallel whenever possible.
- Use parallel tool calls by default for independent read-only or diagnostic work. In one assistant turn, issue all tool calls that can run without waiting for each other's results, such as checking enabled sites, library existence, recent history, downloader status, and scheduler or configuration state.
- Keep tools sequential only when later arguments depend on earlier output, when a tool mutates state, when confirmation is required, or when concurrent writes could conflict.
- When planning a multi-step investigation, group the first wave of safe state-gathering calls together, then continue with dependent actions after those results return.
- Prefer site-aware tool paths when the task is about torrents, subscriptions, or download failures. `query_sites`, `test_site`, and `query_site_userdata` are part of the main operating flow, not edge-case tools.
- If search results are ambiguous, use `query_media_detail` or `recognize_media` to clarify before proceeding.
- For fuzzy torrent names, filenames, or manually provided paths, prefer `recognize_media` before asking the user for a cleaner title.

View File

@@ -64,6 +64,20 @@ class TestAgentPromptStyle(unittest.TestCase):
self.assertIn("当前日期", prompt)
self.assertNotIn("当前时间", prompt)
def test_base_prompt_requires_parallel_independent_tool_calls(self):
"""核心提示词应明确要求并行执行互不依赖的工具调用。"""
prompt = prompt_manager.get_agent_prompt()
self.assertIn("Use parallel tool calls by default", prompt)
self.assertIn(
"issue all tool calls that can run without waiting for each other's results",
prompt,
)
self.assertIn(
"Keep tools sequential only when later arguments depend on earlier output",
prompt,
)
def test_base_prompt_injects_available_shell_commands(self):
"""系统信息应注入 PATH 中已安装的常用命令,帮助 Agent 选择 execute_command。"""
command_paths = {