| 1 | # skills_tool.py DOX |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | - Own the `skills_tool.py` agent tool. |
| 6 | - This module searches, loads, and lists Agent Zero skills and exposes effective slash-command definitions for the agent. |
| 7 | - Keep this file-level DOX profile synchronized with `skills_tool.py` because this directory is intentionally flat. |
| 8 | |
| 9 | ## Ownership |
| 10 | |
| 11 | - `skills_tool.py` owns the runtime implementation. |
| 12 | - `skills_tool.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation. |
| 13 | - Classes: |
| 14 | - `SkillsTool` (`Tool`) |
| 15 | - `get_log_object(self)` |
| 16 | - `async before_execution(self, **kwargs)` |
| 17 | - `async execute(self, **kwargs) -> Response` |
| 18 | - `_visible_skill_loaded(self, skill_name: str) -> bool` |
| 19 | - Top-level functions: |
| 20 | - `max_loaded_skills() -> int` |
| 21 | - Notable constants/configuration names: `DATA_NAME_LOADED_SKILLS`. |
| 22 | |
| 23 | ## Runtime Contracts |
| 24 | |
| 25 | - Tool modules must define `helpers.tool.Tool` subclasses and return `helpers.tool.Response` from `execute(...)`. |
| 26 | - Update this file whenever tool arguments, output shape, `break_loop` behavior, intervention handling, prompt instructions, or side effects change. |
| 27 | - `SkillsTool` is a `Tool`. |
| 28 | - `SkillsTool` defines `execute(...)`. |
| 29 | - Loading a skill appends the full skill body as a normal tool-result history message with `skill_instructions` metadata containing name, path, source, and content visibility. |
| 30 | - Loaded skill IDs are stored in chat-wide context data. |
| 31 | - Duplicate loads omit the full body when the same skill name remains visible in model history. |
| 32 | - Missing or empty `action` defaults to `list`, and legacy `method` is accepted as a deprecated alias when `action` is absent. |
| 33 | - Observed side-effect areas: filesystem reads, filesystem deletion, settings/state persistence, chat history persistence. |
| 34 | - Imported dependency areas include: `__future__`, `helpers`, `helpers.print_style`, `helpers.tool`, `pathlib`, `typing`. |
| 35 | |
| 36 | ## Key Concepts |
| 37 | |
| 38 | - Important called helpers/classes observed in the source: `str.strip.lower.replace`, `skill_name.strip`, `super.get_log_object`, `self._normalize_skill_name`, `self.get_log_object`, `skills_helper.list_skills`, `join`, `skills_helper.search_skills`, `skills_helper.find_skill`, `skills_helper.load_skill_for_agent`, `skills_helper.add_loaded_skill_name`, `skills_helper.skill_instruction_name`, `skill.path.resolve`, `Path`, `resolved.read_text`, `skill_name.startswith`, `skill_name.endswith`, `self._current_action`, `self.agent.context.log.log`, `Response`, `strip`, `target.is_absolute`. |
| 39 | - Keep request/response, tool, or helper semantics documented here at the same time as source changes. |
| 40 | |
| 41 | ## Work Guidance |
| 42 | |
| 43 | - Keep tool output concise, model-readable, and safe for history persistence. |
| 44 | - Coordinate argument or behavior changes with prompt tool instructions and skill guidance. |
| 45 | - Respect intervention flow for long-running, external, or user-visible operations. |
| 46 | |
| 47 | ## Verification |
| 48 | |
| 49 | - Run targeted tool and prompt-contract tests for changed behavior; smoke-test agent execution when no focused test exists. |
| 50 | - Related tests observed by source search: |
| 51 | - `tests/test_document_query_plugin.py` |
| 52 | - `tests/test_tool_action_contracts.py` |
| 53 | |
| 54 | ## Child DOX Index |
| 55 | |
| 56 | No child DOX files. |