Files
devplacepy/tests/unit/services/devii/agents/tools.py
T
retoor 3bfde87fdb Introduce Devii agents subsystem with supervisor, policy, and evals
- Add agents package: controller, runner, store, tools, actions, evals, policy
- Wire agents into Devii service, session, registry, CLI, and dispatcher
- Extend database schema and config for agent persistence
- Add news and telegram bridge updates plus landing UI and docs
- Cover agents, news, and telegram flows with unit tests
2026-10-26 02:54:44 +01:00

74 lines
2.3 KiB
Python

# retoor <retoor@molodetz.nl>
from devplacepy.services.devii.agents.policy import ORCHESTRATOR_ONLY_TOOLS
from devplacepy.services.devii.agents.tools import build_subagent_tools
from devplacepy.services.devii.registry import CATALOG
def _names(schemas):
return {s["function"]["name"] for s in schemas}
def _parent():
return CATALOG.tool_schemas_for(
authenticated=True, is_admin=False, is_primary_admin=False
)
def test_inherits_parent_minus_denied_plus_ask():
schemas = build_subagent_tools(_parent(), "research", (), True, False, False)
names = _names(schemas)
assert "ask_user" in names
assert "rsearch" in names
assert "ui_prompt" not in names
assert "run_js" not in names
assert "avatar_show" not in names
assert "agent_start" not in names
assert "delegate" in names
assert not (names & ORCHESTRATOR_ONLY_TOOLS)
def test_extras_union_and_role_filter():
schemas = build_subagent_tools(
_parent(), "long-mutation", ("container_exec",), True, False, False
)
names = _names(schemas)
assert "container_exec" not in names
schemas = build_subagent_tools(
CATALOG.tool_schemas_for(
authenticated=True, is_admin=True, is_primary_admin=False
),
"long-mutation",
("container_exec",),
True,
True,
False,
)
assert "container_exec" in _names(schemas)
def test_guests_lose_authed_tools_everywhere():
guest = CATALOG.tool_schemas_for(
authenticated=False, is_admin=False, is_primary_admin=False
)
schemas = build_subagent_tools(guest, "research", ("create_post",), False, False, False)
names = _names(schemas)
assert "create_post" not in names
assert "fetch_url" in names
assert "ask_user" in names
def test_no_drift_when_catalog_grows():
parent = _parent()
schemas = build_subagent_tools(parent, "files", (), True, False, False)
names = _names(schemas)
by_name = CATALOG.by_name()
for action in CATALOG.actions:
if action.name in ORCHESTRATOR_ONLY_TOOLS:
assert action.name not in names
elif action.name == "ask_user":
assert action.name in names
elif not action.requires_auth and not action.requires_admin:
assert action.name in names
assert by_name["project_write_file"].name in names