Files
agent-zero/extensions/python/system_prompt/_13_skills_prompt.py
Alessandro 0e3d267f79 feat: add per-action permissions for bundled tools
Let profiles allow individual operations across all 12 bundled multi-action
tools, such as reading files without allowing writes or listing scheduled
tasks without allowing deletion.

Share action contracts across runtime policy, Agent Editor, text prompts,
and native schemas. Preserve existing whole-tool policies and legacy memory
IDs; only explicit permission edits persist the editor's projection.

Check aliases, defaults, browser batches, reset flags, and parallel
operations at execution. Apply action permissions to automatic browser
context and skill hints.

Validation: 742 focused tests passed. Live Docker checks verified allowed
reads, denied writes through native/legacy/parallel dispatch, blocked
scheduler deletion, and editor save/reload.
2026-10-27 19:06:13 +01:00

44 lines
1.2 KiB
Python

from typing import Any
from helpers.extension import Extension, extensible
from helpers import skills as skills_helper, tool_policy
from agent import Agent, LoopData
class SkillsPrompt(Extension):
async def execute(
self,
system_prompt: list[str] = [],
loop_data: LoopData = LoopData(),
**kwargs: Any,
):
if not self.agent:
return
prompt = await build_prompt(self.agent)
if prompt:
system_prompt.append(prompt)
@extensible
async def build_prompt(agent: Agent) -> str:
if not all(
tool_policy.resolve_tool(agent, "skills_tool", action=action).allowed
for action in ("list", "load")
):
return ""
available = skills_helper.list_skills(agent=agent)
result: list[str] = []
for skill in available:
name = skill.name.strip().replace("\n", " ")[:100]
descr = skill.description.replace("\n", " ").strip()
if len(descr) > 100:
descr = descr[:100].rstrip() + "..."
result.append(f"- {name}: {descr}" if descr else f"- {name}")
if not result:
return ""
return agent.read_prompt("agent.system.skills.md", skills="\n".join(result))