mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-05-17 04:01:13 +00:00
Standardize multi-action tools around tool_args.action while keeping parser compatibility for older tool/args, tool_name:action, and method-shaped requests. This keeps new prompts clean without breaking agents that learned the previous dialect. Move A0 connector remote execution/file tools into stable standard prompts, make remote targeting independent of the active chat context, and skill-gate beta computer-use remote so it no longer weighs down the always-on tool list. Align text editor, scheduler, skills, office artifact, memory, notify, and browser prompts/tools around the canonical action contract. Add scheduler update/timezone handling, skills_tool read_file, text editor patch coverage, and fixes for memory_forget, behaviour_adjustment, and code execution progress warnings. Reduce default prompt pressure by compacting browser and scheduler prompts into skill-backed manifests, shortening skill catalog descriptions, and pruning noisy framework knowledge. Remove obsolete connector prompt stubs and root tool-call knowledge examples. Tests: conda run -n a0 pytest tests/test_a0_connector_prompt_gating.py tests/test_tool_action_contracts.py tests/test_task_scheduler_timezone.py tests/test_text_editor_context_patch.py tests/test_tool_request_normalization.py tests/test_office_document_store.py::test_odf_is_advertised_and_docx_remains_explicit_compatibility tests/test_office_document_store.py::test_document_artifact_accepts_method_alias_for_ods_create tests/test_skills_runtime.py tests/test_default_prompt_budget.py::test_a0_small_profile_removed_and_prompt_text_generic -q
67 lines
2.2 KiB
Python
67 lines
2.2 KiB
Python
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
|
if str(PROJECT_ROOT) not in sys.path:
|
|
sys.path.insert(0, str(PROJECT_ROOT))
|
|
|
|
from helpers.extract_tools import normalize_tool_request
|
|
|
|
|
|
def test_normalize_tool_request_accepts_canonical_keys() -> None:
|
|
assert normalize_tool_request({"tool_name": "response", "tool_args": {"text": "ok"}}) == (
|
|
"response",
|
|
{"text": "ok"},
|
|
)
|
|
|
|
|
|
def test_normalize_tool_request_accepts_fallback_keys() -> None:
|
|
assert normalize_tool_request({"tool": "response", "args": {"text": "ok"}}) == (
|
|
"response",
|
|
{"text": "ok"},
|
|
)
|
|
|
|
|
|
def test_normalize_tool_request_uses_fallback_when_canonical_name_is_empty() -> None:
|
|
assert normalize_tool_request(
|
|
{"tool_name": "", "tool": "response", "args": {"text": "ok"}}
|
|
) == ("response", {"text": "ok"})
|
|
|
|
|
|
def test_normalize_tool_request_uses_fallback_when_canonical_args_are_invalid() -> None:
|
|
assert normalize_tool_request(
|
|
{"tool_name": "response", "tool_args": None, "args": {"text": "ok"}}
|
|
) == ("response", {"text": "ok"})
|
|
|
|
|
|
def test_normalize_tool_request_translates_method_suffix_to_action() -> None:
|
|
assert normalize_tool_request(
|
|
{"tool_name": "text_editor:read", "tool_args": {"path": "README.md"}}
|
|
) == ("text_editor", {"path": "README.md", "action": "read"})
|
|
|
|
|
|
def test_normalize_tool_request_translates_method_arg_to_action() -> None:
|
|
assert normalize_tool_request(
|
|
{"tool_name": "scheduler", "tool_args": {"method": "list_tasks"}}
|
|
) == ("scheduler", {"method": "list_tasks", "action": "list_tasks"})
|
|
|
|
|
|
def test_normalize_tool_request_preserves_explicit_action_over_method() -> None:
|
|
assert normalize_tool_request(
|
|
{
|
|
"tool_name": "scheduler:delete_task",
|
|
"tool_args": {"method": "list_tasks", "action": "show_task"},
|
|
}
|
|
) == (
|
|
"scheduler",
|
|
{"method": "list_tasks", "action": "show_task"},
|
|
)
|
|
|
|
|
|
def test_normalize_tool_request_rejects_missing_args() -> None:
|
|
with pytest.raises(ValueError, match="tool_args"):
|
|
normalize_tool_request({"tool_name": "response"})
|