Agent Zero AI framework
Keep slash commands out of agent skills
Alessandro864e311c6046
diff --git a/helpers/skills.py b/helpers/skills.pyindex c5461b714..65bd1018c 100644--- a/helpers/skills.py+++ b/helpers/skills.py@@ -400,54 +400,6 @@ def list_skills(return _filter_hidden_skills(agent, result)-def list_slash_commands(agent: Agent | None = None) -> list[dict[str, Any]]:- """List effective, picker-visible slash commands for the agent's project."""- # Local import avoids the commands helper's import of split_frontmatter above.- from plugins._commands.helpers import commands as commands_helper-- commands, _ = commands_helper.list_effective_commands(- _get_agent_project_name(agent)- )- return [- command- for command in commands- if not bool((command.get("frontmatter_extra") or {}).get("webui_hidden"))- ]---def find_slash_command(- command_name: str,- agent: Agent | None = None,-) -> dict[str, Any] | None:- """Find one effective slash command by its canonical ``/name``."""- target = str(command_name or "").strip().lstrip("/").lower()- if not target:- return None- return next(- (command for command in list_slash_commands(agent) if command["name"] == target),- None,- )---def format_slash_command(command: dict[str, Any]) -> str:- """Render a slash command definition for a skills-tool result."""- lines = [f"Slash command: /{command['name']}"]- if description := str(command.get("description") or "").strip():- lines.append(f"Description: {description}")- if argument_hint := str(command.get("argument_hint") or "").strip():- lines.append(f"Arguments: {argument_hint}")- lines.append(f"Type: {command.get('command_type') or 'text'}")- if scope := str(command.get("scope_label") or "").strip():- lines.append(f"Scope: {scope}")-- body = str(command.get("body") or "").strip()- if body:- if len(body) > 24000:- body = body[:24000].rstrip() + "\n\n[truncated]"- lines.extend(["", "Definition:", body])- return "\n".join(lines)--def delete_skill(skill_path: str,) -> None:diff --git a/helpers/skills.py.dox.md b/helpers/skills.py.dox.mdindex 6149b78d5..91de81bc7 100644--- a/helpers/skills.py.dox.md+++ b/helpers/skills.py.dox.md@@ -27,9 +27,6 @@- `parse_frontmatter(frontmatter_text: str) -> Tuple[Dict[str, Any], List[str]]`: Parse YAML frontmatter with PyYAML when available,- `skill_from_markdown(skill_md_path: Path, include_content: bool=..., validate: bool=...) -> Optional[Skill]`- `list_skills(agent: Agent | None=..., include_content: bool=..., include_hidden: bool=...) -> List[Skill]`: List skills, optionally filtered by agent scope.-- `list_slash_commands(agent: Agent | None=...) -> list[dict[str, Any]]`: List picker-visible effective slash commands for the agent project.-- `find_slash_command(command_name: str, agent: Agent | None=...) -> dict[str, Any] | None`-- `format_slash_command(command: dict[str, Any]) -> str`- `delete_skill(skill_path: str) -> None`: Delete a skill directory.- `find_skill(skill_name: str, agent: Agent | None=..., include_content: bool=..., include_hidden: bool=..., validate: bool=...) -> Optional[Skill]`- `load_skill_for_agent(skill_name: str, agent: Agent | None=...) -> str`: Load skill and format it as a complete string for agent context.diff --git a/prompts/agent.system.tool.skills.md b/prompts/agent.system.tool.skills.mdindex 01861f3f4..c9e5ad4f7 100644--- a/prompts/agent.system.tool.skills.md+++ b/prompts/agent.system.tool.skills.md@@ -5,7 +5,7 @@ common args: action skill_name query file_pathworkflow:- action `search`: find candidate skills by keywords or trigger phrases from the current task- action `list`: discover available skills-- action `load`: append one skill's full instructions to chat history by `skill_name`; use `skill_name=/command` to read an effective slash-command definition without invoking it+- action `load`: append one skill's full instructions to chat history by `skill_name`- action `read_file`: open one file inside a loaded skill directoryif the user says "find/search a skill", call `search` before `load` even when the likely skill name seems obvious`read_file` requires both `skill_name` and `file_path`; load the skill first, then read `SKILL.md` or the named relative filediff --git a/tests/test_skills_runtime.py b/tests/test_skills_runtime.pyindex 88f6f87f9..e7dd26ac8 100644--- a/tests/test_skills_runtime.py+++ b/tests/test_skills_runtime.py@@ -141,63 +141,6 @@ def test_active_skills_cap_is_twenty():assert runtime.get_max_active_skills() == 20-def test_slash_commands_use_agent_scope_and_hide_picker_hidden(monkeypatch):- plugins_pkg = types.ModuleType("plugins")- plugins_pkg.__path__ = []- commands_plugin_pkg = types.ModuleType("plugins._commands")- commands_plugin_pkg.__path__ = []- commands_helpers_pkg = types.ModuleType("plugins._commands.helpers")- commands_helpers_pkg.__path__ = []- commands = types.ModuleType("plugins._commands.helpers.commands")- calls = []- commands.list_effective_commands = lambda project_name: (- [- {- "name": "visible",- "description": "Visible command.",- "argument_hint": "<text>",- "command_type": "text",- "scope_label": "Project",- "body": "Template {text}",- "frontmatter_extra": {},- },- {- "name": "hidden",- "frontmatter_extra": {"webui_hidden": True},- },- ],- {"project_name": project_name},- )- commands_helpers_pkg.commands = commands- for name, module in (- ("plugins", plugins_pkg),- ("plugins._commands", commands_plugin_pkg),- ("plugins._commands.helpers", commands_helpers_pkg),- ("plugins._commands.helpers.commands", commands),- ):- monkeypatch.setitem(sys.modules, name, module)- monkeypatch.setattr(- runtime,- "_get_agent_project_name",- lambda _agent: calls.append("project") or "project",- )-- command = runtime.find_slash_command("/visible", DummyAgent())-- assert calls == ["project"]- assert command["name"] == "visible"- assert runtime.find_slash_command("/hidden", DummyAgent()) is None- assert runtime.format_slash_command(command) == (- "Slash command: /visible\n"- "Description: Visible command.\n"- "Arguments: <text>\n"- "Type: text\n"- "Scope: Project\n\n"- "Definition:\n"- "Template {text}"- )--def test_skills_config_can_raise_active_cap_above_default():config = runtime.normalize_skills_config({diff --git a/tests/test_tool_action_contracts.py b/tests/test_tool_action_contracts.pyindex d5af1c53e..8e15c57b0 100644--- a/tests/test_tool_action_contracts.py+++ b/tests/test_tool_action_contracts.py@@ -130,20 +130,6 @@ def _load_skills_tool(monkeypatch, skill_root: Path):tags=[],)skills_stub.list_skills = lambda *args, **kwargs: [fake_skill]- fake_command = {- "name": "summarize",- "description": "Summarize the current work.",- "argument_hint": "[focus]",- }- skills_stub.list_slash_commands = lambda *args, **kwargs: [fake_command]- skills_stub.find_slash_command = (- lambda command_name, *args, **kwargs: (- fake_command if command_name == "/summarize" else None- )- )- skills_stub.format_slash_command = (- lambda command: f"Slash command: /{command['name']}\nDefinition: prompt"- )skills_stub.search_skills = lambda *args, **kwargs: [fake_skill]skills_stub.find_skill = lambda *args, **kwargs: fake_skillskills_stub.load_skill_for_agent = (@@ -359,28 +345,7 @@ def test_skills_tool_defaults_missing_action_to_list(monkeypatch, tmp_path: Pathassert "Available skills" in response.messageassert "browser-form-workflows" in response.message- assert "Available slash commands" in response.message- assert "/summarize [focus]" in response.message---def test_skills_tool_load_reads_slash_command_without_loading_a_skill(- monkeypatch, tmp_path: Path-):- module = _load_skills_tool(monkeypatch, tmp_path)- agent = _FakeAgent()- tool = module.SkillsTool(- agent,- "skills_tool",- None,- {"action": "load", "skill_name": "/summarize"},- "",- None,- )-- response = asyncio.run(tool.execute(**tool.args))-- assert response.message == "Slash command: /summarize\nDefinition: prompt"- assert agent.context.get_data("loaded_skills") is None+ assert "slash commands" not in response.messagedef test_skills_tool_load_appends_skill_instructions_as_tool_result(diff --git a/tools/skills_tool.py b/tools/skills_tool.pyindex 13cfc4df7..babb807d0 100644--- a/tools/skills_tool.py+++ b/tools/skills_tool.py@@ -18,7 +18,7 @@ class SkillsTool(Tool):Actions (tool_args.action):- list- search (query)- - load (skill_name, or /command)+ - load (skill_name)- read_file (skill_name, file_path)Script execution is handled by code_execution_tool directly.@@ -144,38 +144,20 @@ class SkillsTool(Tool):agent=self.agent,include_content=False,)- commands = skills_helper.list_slash_commands(agent=self.agent)- if not skills and not commands:- return "No skills or slash commands found."-- lines: List[str] = []- if skills:- # Stable output: sort by name- skills_sorted = sorted(skills, key=lambda s: s.name.lower())- lines.append(f"Available skills ({len(skills_sorted)}):")- for s in skills_sorted:- tags = f" tags={','.join(s.tags)}" if s.tags else ""- ver = f" v{s.version}" if s.version else ""- desc = (s.description or "").strip()- if len(desc) > 200:- desc = desc[:200].rstrip() + "..."- lines.append(f"- {s.name}{ver}{tags}: {desc}")-- if commands:- if lines:- lines.append("")- lines.append(f"Available slash commands ({len(commands)}):")- for command in commands:- arguments = str(command.get("argument_hint") or "").strip()- desc = str(command.get("description") or "").strip()- if len(desc) > 200:- desc = desc[:200].rstrip() + "..."- suffix = f" {arguments}" if arguments else ""- lines.append(f"- /{command['name']}{suffix}: {desc}")+ if not skills:+ return "No skills found."++ skills_sorted = sorted(skills, key=lambda s: s.name.lower())+ lines = [f"Available skills ({len(skills_sorted)}):"]+ for s in skills_sorted:+ tags = f" tags={','.join(s.tags)}" if s.tags else ""+ ver = f" v{s.version}" if s.version else ""+ desc = (s.description or "").strip()+ if len(desc) > 200:+ desc = desc[:200].rstrip() + "..."+ lines.append(f"- {s.name}{ver}{tags}: {desc}")lines.append("")- lines.append(- "Tip: use skills_tool action=search for skills or action=load skill_name=/name to read a slash command."- )+ lines.append("Tip: use skills_tool action=search or action=load for details.")return "\n".join(lines)def _search(self, query: str) -> str:@@ -212,21 +194,6 @@ class SkillsTool(Tool):break_loop=False,)- if skill_name.startswith("/"):- command = skills_helper.find_slash_command(skill_name, agent=self.agent)- if not command:- return Response(- message=(- f"Error: slash command not found: {skill_name!r}. "- "Try skills_tool action=list."- ),- break_loop=False,- )- return Response(- message=skills_helper.format_slash_command(command),- break_loop=False,- )-# Verify skill existsskill = skills_helper.find_skill(skill_name,diff --git a/tools/skills_tool.py.dox.md b/tools/skills_tool.py.dox.mdindex dc0473be8..7100c7c3d 100644--- a/tools/skills_tool.py.dox.md+++ b/tools/skills_tool.py.dox.md@@ -30,7 +30,6 @@- Loaded skill IDs are stored in chat-wide context data.- Duplicate loads omit the full body when the same skill name remains visible in model history.- Missing or empty `action` defaults to `list`, and legacy `method` is accepted as a deprecated alias when `action` is absent.-- `list` includes picker-visible slash commands for the active project. `load` with `skill_name=/name` reads the effective command definition without executing it or adding it to the loaded-skill ledger.- Observed side-effect areas: filesystem reads, filesystem deletion, settings/state persistence, chat history persistence.- Imported dependency areas include: `__future__`, `helpers`, `helpers.print_style`, `helpers.tool`, `pathlib`, `typing`.