feat: focus Work tools by task intent

This commit is contained in:
wuyang
2026-07-26 14:22:46 +08:00
parent ae5f940a5d
commit f2282c7e7d
3 changed files with 85 additions and 3 deletions
+29
View File
@@ -11,6 +11,7 @@ from agent_platform.runtime.loop import (
AgentLoop,
is_substantive_execution,
normalize_write_file_content,
select_tool_specs,
tool_event_details,
)
from agent_platform.runtime.tools import TOOL_METADATA
@@ -45,6 +46,34 @@ def test_read_only_shell_commands_do_not_satisfy_execution_evidence() -> None:
assert is_substantive_execution("start_process", {"command": "python3 server.py"})
def test_simple_script_task_receives_a_focused_tool_menu() -> None:
specs = [metadata.openai_spec() for metadata in TOOL_METADATA.values()]
selected = select_tool_specs(specs, "写脚本对比排序算法,给一个报告", depth=0)
names = {spec["function"]["name"] for spec in selected}
assert names == {
"workspace_status",
"list_files",
"read_file",
"search_files",
"write_file",
"apply_patch",
"exec",
"update_plan",
}
def test_complex_requests_enable_only_relevant_optional_tools() -> None:
specs = [metadata.openai_spec() for metadata in TOOL_METADATA.values()]
selected = select_tool_specs(
specs,
"重构 Git 仓库里的 web server,并记住这个偏好,分工并行调研",
depth=0,
)
names = {spec["function"]["name"] for spec in selected}
assert {"delegate_task", "git_status", "git_diff", "start_process", "poll_process"} <= names
assert {"remember", "recall_memory", "forget_memory"} <= names
class ScriptedProvider:
def __init__(self, responses: list[dict[str, Any]]) -> None:
self.responses = responses