Add load_skill tool to bypass workspace restriction for builtin skills
When restrictToWorkspace is enabled, the agent cannot read builtin skill files via read_file since they live outside the workspace. This adds a dedicated load_skill tool that reads skills by name through the SkillsLoader, which accesses files directly via Python without the workspace restriction. - Add LoadSkillTool to filesystem tools - Register it in the agent loop - Update system prompt to instruct agent to use load_skill instead of read_file - Remove raw filesystem paths from skills summary
This commit is contained in:
@@ -363,3 +363,35 @@ class ListDirTool(_FsTool):
|
||||
return f"Error: {e}"
|
||||
except Exception as e:
|
||||
return f"Error listing directory: {e}"
|
||||
|
||||
|
||||
class LoadSkillTool(Tool):
|
||||
"""Tool to load a skill by name, bypassing workspace restriction."""
|
||||
|
||||
def __init__(self, skills_loader):
|
||||
self._skills_loader = skills_loader
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return "load_skill"
|
||||
|
||||
@property
|
||||
def description(self) -> str:
|
||||
return "Load a skill by name. Returns the full SKILL.md content."
|
||||
|
||||
@property
|
||||
def parameters(self) -> dict[str, Any]:
|
||||
return {
|
||||
"type": "object",
|
||||
"properties": {"name": {"type": "string", "description": "The skill name to load"}},
|
||||
"required": ["name"],
|
||||
}
|
||||
|
||||
async def execute(self, name: str, **kwargs: Any) -> str:
|
||||
try:
|
||||
content = self._skills_loader.load_skill(name)
|
||||
if content is None:
|
||||
return f"Error: Skill not found: {name}"
|
||||
return content
|
||||
except Exception as e:
|
||||
return f"Error loading skill: {str(e)}"
|
||||
|
||||
Reference in New Issue
Block a user