Skip to content

Agent Zero AI framework

skills cleanup, minor fixes

frdel724e06ae9d84
diff --git a/.dockerignore b/.dockerignore
index 46405579d..f69e04aa1 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -2,15 +2,14 @@
# Project‑specific exclusions / re‑includes
###############################################################################
-# Large / generated data
+# Obsolete
memory/**
+instruments/**
# Logs, tmp, usr
logs/*
tmp/*
usr/*
-!usr/skills/
-!usr/skills/**
# Knowledge directory – keep only default/
knowledge/**
diff --git a/prompts/agent.system.skills.md b/prompts/agent.system.skills.md
index ae4f59f62..4b97f7050 100644
--- a/prompts/agent.system.skills.md
+++ b/prompts/agent.system.skills.md
@@ -1,5 +1,6 @@
-# Relevant Skills (SKILL.md)
-- The following Skills may be useful for the current task.
-- Use `skills_tool` to list/search/load skills and progressively read supporting files/scripts.
+# Available skills
+- skills in "**name** description" format
+- use skills_tool to load with **skill_name** when relevant
+
{{skills}}
diff --git a/python/api/api_reset_chat.py b/python/api/api_reset_chat.py
index bf0a10f8a..d2d45f1b2 100644
--- a/python/api/api_reset_chat.py
+++ b/python/api/api_reset_chat.py
@@ -47,6 +47,7 @@ class ApiResetChat(ApiHandler):
context.reset()
# Save the reset context to persist the changes
persist_chat.save_tmp_chat(context)
+ persist_chat.remove_msg_files(context_id)
# Log the reset
PrintStyle(
diff --git a/python/extensions/message_loop_prompts_after/_55_recall_skills.py b/python/extensions/message_loop_prompts_after/_55_recall_skills.py
deleted file mode 100644
index 89be65e89..000000000
--- a/python/extensions/message_loop_prompts_after/_55_recall_skills.py
+++ /dev/null
@@ -1,53 +0,0 @@
-from python.helpers.extension import Extension
-from agent import LoopData
-from python.helpers import skills as skills_helper
-from python.helpers import projects
-
-
-class RecallSkills(Extension):
- """
- Surface relevant SKILL.md-based Skills into the prompt (token-efficient).
-
- Uses lightweight lexical matching and injects a compact
- "relevant skills" list into extras for the current user message.
- """
-
- async def execute(self, loop_data: LoopData = LoopData(), **kwargs):
- # Only on the first iteration of the message loop (new user instruction)
- if loop_data.iteration != 0:
- return
-
- # Determine query from current user message
- user_instruction = (
- loop_data.user_message.output_text() if loop_data.user_message else ""
- ).strip()
- if not user_instruction or len(user_instruction) < 8:
- return
-
- # Get active project for scoped discovery
- project_name = (
- projects.get_context_project_name(self.agent.context)
- if self.agent.context
- else None
- )
-
- matches = skills_helper.search_skills(
- user_instruction,
- limit=6,
- project_name=project_name,
- )
- if not matches:
- return
-
- lines = []
- for s in matches:
- desc = (s.description or "").strip() or "(no description)"
- if len(desc) > 220:
- desc = desc[:220].rstrip() + "…"
- lines.append(f"- {s.name} [{s.source}]: {desc}")
-
- skills_block = "\n".join(lines)
- loop_data.extras_temporary["skills"] = self.agent.parse_prompt(
- "agent.system.skills.md", skills=skills_block
- )
-
diff --git a/python/extensions/system_prompt/_10_system_prompt.py b/python/extensions/system_prompt/_10_system_prompt.py
index fc5c109d9..40fc5f030 100644
--- a/python/extensions/system_prompt/_10_system_prompt.py
+++ b/python/extensions/system_prompt/_10_system_prompt.py
@@ -3,7 +3,7 @@ from python.helpers.extension import Extension
from python.helpers.mcp_handler import MCPConfig
from agent import Agent, LoopData
from python.helpers.settings import get_settings
-from python.helpers import projects
+from python.helpers import projects, skills
class SystemPrompt(Extension):
@@ -18,6 +18,7 @@ class SystemPrompt(Extension):
main = get_main_prompt(self.agent)
tools = get_tools_prompt(self.agent)
mcp_tools = get_mcp_tools_prompt(self.agent)
+ skills = get_skills_prompt(self.agent)
secrets_prompt = get_secrets_prompt(self.agent)
project_prompt = get_project_prompt(self.agent)
@@ -25,11 +26,13 @@ class SystemPrompt(Extension):
system_prompt.append(tools)
if mcp_tools:
system_prompt.append(mcp_tools)
+ if skills:
+ system_prompt.append(skills)
if secrets_prompt:
system_prompt.append(secrets_prompt)
if project_prompt:
system_prompt.append(project_prompt)
-
+
def get_main_prompt(agent: Agent):
return agent.read_prompt("agent.system.main.md")
@@ -81,4 +84,13 @@ def get_project_prompt(agent: Agent):
result += "\n\n" + agent.read_prompt("agent.system.projects.inactive.md")
return result
+def get_skills_prompt(agent: Agent):
+ available = skills.list_skills(agent)
+ result = []
+ for skill in available:
+ name = skill.name.strip().replace("\n", " ")[:100]
+ descr = skill.description.replace("\n", " ")[:500]
+ result.append(f"**{name}** {descr}")
+ if result:
+ return agent.read_prompt("agent.system.skills.md", skills="\n".join(result))
diff --git a/python/helpers/files.py b/python/helpers/files.py
index 4e7d70003..fc93bbbcf 100644
--- a/python/helpers/files.py
+++ b/python/helpers/files.py
@@ -8,7 +8,7 @@ import re
import base64
import shutil
import tempfile
-from typing import Any
+from typing import Any, Literal
import zipfile
import importlib
import importlib.util
@@ -352,7 +352,7 @@ def find_file_in_dirs(_filename: str, _directories: list[str]):
)
-def get_unique_filenames_in_dirs(dir_paths: list[str], pattern: str = "*"):
+def get_unique_filenames_in_dirs(dir_paths: list[str], type: Literal["file", "dir", "any"] = "file", pattern: str = "*"):
# returns absolute paths for unique filenames, priority by order in dir_paths
seen = set()
result = []
@@ -360,7 +360,7 @@ def get_unique_filenames_in_dirs(dir_paths: list[str], pattern: str = "*"):
full_dir = get_abs_path(dir_path)
for file_path in glob.glob(os.path.join(full_dir, pattern)):
fname = os.path.basename(file_path)
- if fname not in seen and os.path.isfile(file_path):
+ if fname not in seen and (type == "any" or (type == "file" and os.path.isfile(file_path)) or (type == "dir" and os.path.isdir(file_path))):
seen.add(fname)
result.append(get_abs_path(file_path))
# sort by filename (basename), not the full path
@@ -368,6 +368,16 @@ def get_unique_filenames_in_dirs(dir_paths: list[str], pattern: str = "*"):
return result
+def find_existing_paths_by_pattern(pattern: str):
+ if not pattern:
+ return []
+
+ search_pattern = get_abs_path(pattern)
+ matches = glob.glob(search_pattern, recursive=True)
+ matches.sort()
+ return matches
+
+
def remove_code_fences(text):
# Pattern to match code fences with optional language specifier
pattern = r"(```|~~~)(.*?\n)(.*?)(\1)"
diff --git a/python/helpers/migration.py b/python/helpers/migration.py
index f02c79a67..498398c15 100644
--- a/python/helpers/migration.py
+++ b/python/helpers/migration.py
@@ -19,7 +19,6 @@ def migrate_user_data() -> None:
_move_dir("tmp/downloads", "usr/downloads")
_move_dir("tmp/email", "usr/email")
_move_dir("knowledge/custom", "usr/knowledge", overwrite=True)
- _move_dir("skills/custom", "usr/skills/custom", overwrite=True)
# --- Migrate Files -------------------------------------------------------------
# Move specific configuration files to usr/
@@ -37,8 +36,6 @@ def migrate_user_data() -> None:
# We use _merge_dir_contents because we want to move the *contents* of default/
# into the parent directory, not move the default directory itself.
_merge_dir_contents("knowledge/default", "knowledge")
- _merge_dir_contents("skills/default", "usr/skills/default")
- _merge_dir_contents("skills/builtin", "usr/skills/default")
# --- Cleanup -------------------------------------------------------------------
@@ -105,9 +102,6 @@ def _cleanup_obsolete() -> None:
"""
to_remove = [
"knowledge/default",
- "skills/default",
- "skills/builtin",
- "skills",
"memory"
]
for path in to_remove:
diff --git a/python/helpers/skills.py b/python/helpers/skills.py
index 31c41d264..a462bd0b2 100644
--- a/python/helpers/skills.py
+++ b/python/helpers/skills.py
@@ -4,9 +4,12 @@ import os
import re
from dataclasses import dataclass, field
from pathlib import Path
-from typing import Any, Dict, Iterable, List, Literal, Optional, Tuple
+from typing import Any, Dict, Iterable, List, Literal, Optional, Tuple, TYPE_CHECKING
-from python.helpers import files
+from python.helpers import files, subagents
+
+if TYPE_CHECKING:
+ from agent import Agent
try:
import yaml # type: ignore
@@ -14,17 +17,12 @@ except Exception: # pragma: no cover
yaml = None # type: ignore
-SkillSource = Literal["custom", "default", "project"]
-
-
@dataclass(slots=True)
class Skill:
name: str
description: str
path: Path
skill_md_path: Path
- source: SkillSource
-
version: str = ""
author: str = ""
tags: List[str] = field(default_factory=list)
@@ -44,24 +42,20 @@ def get_skills_base_dir() -> Path:
def get_skill_roots(
- order: Optional[List[SkillSource]] = None,
- project_name: Optional[str] = None,
-) -> List[Tuple[SkillSource, Path]]:
- base = get_skills_base_dir()
- order = order or ["custom", "default"]
- roots: List[Tuple[SkillSource, Path]] = [(src, base / src) for src in order]
-
- # Include project-scoped skills if a project is active
- if project_name:
- try:
- from python.helpers.skills_import import get_project_skills_folder
- project_skills = get_project_skills_folder(project_name)
- if project_skills.exists():
- roots.insert(0, ("project", project_skills))
- except Exception:
- pass
+ agent: Agent|None=None,
+) -> List[str]:
+
+ if agent:
+ # skill roots available to agent
+ paths = subagents.get_paths(agent, "skills")
+ else:
+ # skill roots available globally
+ pr_ag = files.find_existing_paths_by_pattern("projects/*/.a0proj/agents/*/skills") # agents in projects
+ projects = files.find_existing_paths_by_pattern("projects/*/.a0proj/skills") # projects
+ agents = files.find_existing_paths_by_pattern("agents/*/skills") # agents
+ paths = [files.get_abs_path("skills"), files.get_abs_path("usr/skills")] + pr_ag + projects + agents # full scope
- return roots
+ return paths
def _is_hidden_path(path: Path) -> bool:
@@ -223,7 +217,6 @@ def parse_frontmatter(frontmatter_text: str) -> Tuple[Dict[str, Any], List[str]]
def skill_from_markdown(
skill_md_path: Path,
- source: SkillSource,
*,
include_content: bool = False,
validate: bool = True,
@@ -272,7 +265,6 @@ def skill_from_markdown(
description=description,
path=skill_dir,
skill_md_path=skill_md_path,
- source=source,
version=version,
author=author,
tags=tags,
@@ -292,25 +284,21 @@ def skill_from_markdown(
def list_skills(
- *,
+ agent:Agent|None=None,
include_content: bool = False,
- dedupe: bool = True,
- root_order: Optional[List[SkillSource]] = None,
- project_name: Optional[str] = None,
) -> List[Skill]:
skills: List[Skill] = []
- roots = get_skill_roots(
- order=root_order,
- project_name=project_name,
- )
- for source, root in roots:
- for skill_md in discover_skill_md_files(root):
- s = skill_from_markdown(skill_md, source, include_content=include_content)
+ roots = get_skill_roots(agent)
+
+ for root in roots:
+ for skill_md in discover_skill_md_files(Path(root)):
+ s = skill_from_markdown(skill_md, include_content=include_content)
if s:
skills.append(s)
- if not dedupe:
+ # no deduplication for global skills
+ if not agent:
return skills
# Dedupe by normalized name, preserving root_order priority (earlier wins)
@@ -324,22 +312,18 @@ def list_skills(
def find_skill(
skill_name: str,
- *,
+ agent:Agent|None=None,
include_content: bool = False,
- root_order: Optional[List[SkillSource]] = None,
- project_name: Optional[str] = None,
) -> Optional[Skill]:
target = _normalize_name(skill_name)
if not target:
return None
- roots = get_skill_roots(
- order=root_order,
- project_name=project_name,
- )
- for source, root in roots:
- for skill_md in discover_skill_md_files(root):
- s = skill_from_markdown(skill_md, source, include_content=include_content)
+ roots = get_skill_roots(agent)
+
+ for root in roots:
+ for skill_md in discover_skill_md_files(Path(root)):
+ s = skill_from_markdown(skill_md, include_content=include_content)
if not s:
continue
if _normalize_name(s.name) == target or _normalize_name(s.path.name) == target:
@@ -349,20 +333,15 @@ def find_skill(
def search_skills(
query: str,
- *,
limit: int = 25,
- project_name: Optional[str] = None,
+ agent: Agent|None=None,
) -> List[Skill]:
q = (query or "").strip().lower()
if not q:
return []
terms = [t for t in re.split(r"\s+", q) if t]
- candidates = list_skills(
- include_content=False,
- dedupe=True,
- project_name=project_name,
- )
+ candidates = list_skills(agent)
scored: List[Tuple[int, Skill]] = []
for s in candidates:
@@ -419,7 +398,7 @@ def validate_skill(skill: Skill) -> List[str]:
return issues
-def validate_skill_md(skill_md_path: Path, source: SkillSource) -> List[str]:
+def validate_skill_md(skill_md_path: Path) -> List[str]:
try:
text = _read_text(skill_md_path)
except Exception:
@@ -430,7 +409,7 @@ def validate_skill_md(skill_md_path: Path, source: SkillSource) -> List[str]:
return fm_errors
skill = skill_from_markdown(
- skill_md_path, source, include_content=False, validate=False
+ skill_md_path, include_content=False, validate=False
)
if not skill:
return ["Unable to parse SKILL.md frontmatter"]
diff --git a/python/tools/skills_tool.py b/python/tools/skills_tool.py
index b4f810fb2..4ae56bc14 100644
--- a/python/tools/skills_tool.py
+++ b/python/tools/skills_tool.py
@@ -22,10 +22,6 @@ class SkillsTool(Tool):
Script execution is handled by code_execution_tool directly.
"""
- def _get_project_name(self) -> str | None:
- ctx = getattr(self.agent, "context", None)
- return projects.get_context_project_name(ctx) if ctx else None
-
async def execute(self, **kwargs) -> Response:
method = (
(kwargs.get("method") or self.args.get("method") or self.method or "")
@@ -60,8 +56,7 @@ class SkillsTool(Tool):
def _list(self) -> str:
skills = skills_helper.list_skills(
include_content=False,
- dedupe=True,
- project_name=self._get_project_name(),
+ agent=self.agent,
)
if not skills:
return (
@@ -70,7 +65,7 @@ class SkillsTool(Tool):
)
# Stable output: sort by name
- skills_sorted = sorted(skills, key=lambda s: (s.name.lower(), s.source))
+ skills_sorted = sorted(skills, key=lambda s: s.name.lower())
lines: List[str] = []
lines.append(f"Available skills ({len(skills_sorted)}):")
@@ -80,7 +75,7 @@ class SkillsTool(Tool):
desc = (s.description or "").strip()
if len(desc) > 200:
desc = desc[:200].rstrip() + "…"
- lines.append(f"- {s.name}{ver} [{s.source}]{tags}: {desc}")
+ lines.append(f"- {s.name}{ver}{tags}: {desc}")
lines.append("")
lines.append("Tip: use skills_tool method=search or method=load for details.")
return "\n".join(lines)
@@ -92,7 +87,7 @@ class SkillsTool(Tool):
results = skills_helper.search_skills(
query,
limit=25,
- project_name=self._get_project_name(),
+ agent=self.agent,
)
if not results:
return f"No skills matched query: {query!r}"
@@ -103,19 +98,24 @@ class SkillsTool(Tool):
desc = (s.description or "").strip()
if len(desc) > 200:
desc = desc[:200].rstrip() + "…"
- lines.append(f"- {s.name} [{s.source}]: {desc}")
+ lines.append(f"- {s.name}: {desc}")
lines.append("")
lines.append("Tip: use skills_tool method=load skill_name=<name> to load full instructions.")
return "\n".join(lines)
def _load(self, skill_name: str) -> str:
+
+ skill_name = skill_name.strip()
+ if skill_name.startswith("**") and skill_name.endswith("**"):
+ skill_name = skill_name[2:-2] # remove markdown bold markers if used by agent
+
if not skill_name:
- return "Error: 'skill_name' is required for method=load."
+ return "Error: 'skill_name' is required for method=load."
skill = skills_helper.find_skill(
skill_name,
include_content=True,
- project_name=self._get_project_name(),
+ agent=self.agent,
)
if not skill:
return f"Error: skill not found: {skill_name!r}. Try skills_tool method=list or method=search."
@@ -130,7 +130,6 @@ class SkillsTool(Tool):
lines: List[str] = []
lines.append(f"Skill: {skill.name}")
- lines.append(f"Source: {skill.source}")
lines.append(f"Path: {rel_skill_dir}")
lines.append(f"Runtime path: {runtime_path}")
if skill.version:
@@ -176,7 +175,7 @@ class SkillsTool(Tool):
skill = skills_helper.find_skill(
skill_name,
include_content=False,
- project_name=self._get_project_name(),
+ agent=self.agent,
)
if not skill:
return f"Error: skill not found: {skill_name!r}."
diff --git a/usr/skills/default/api-development/SKILL.md b/skills/api-development/SKILL.md
similarity index 100%
rename from usr/skills/default/api-development/SKILL.md
rename to skills/api-development/SKILL.md
diff --git a/usr/skills/default/brainstorming/SKILL.md b/skills/brainstorming/SKILL.md
similarity index 100%
rename from usr/skills/default/brainstorming/SKILL.md
rename to skills/brainstorming/SKILL.md
diff --git a/usr/skills/default/code-review/SKILL.md b/skills/code-review/SKILL.md
similarity index 100%
rename from usr/skills/default/code-review/SKILL.md
rename to skills/code-review/SKILL.md
diff --git a/usr/skills/default/create-skill/SKILL.md b/skills/create-skill/SKILL.md
similarity index 100%
rename from usr/skills/default/create-skill/SKILL.md
rename to skills/create-skill/SKILL.md
diff --git a/usr/skills/default/database-design/SKILL.md b/skills/database-design/SKILL.md
similarity index 100%
rename from usr/skills/default/database-design/SKILL.md
rename to skills/database-design/SKILL.md
diff --git a/usr/skills/default/debugging/SKILL.md b/skills/debugging/SKILL.md
similarity index 100%
rename from usr/skills/default/debugging/SKILL.md
rename to skills/debugging/SKILL.md
diff --git a/usr/skills/default/docker-devops/SKILL.md b/skills/docker-devops/SKILL.md
similarity index 100%
rename from usr/skills/default/docker-devops/SKILL.md
rename to skills/docker-devops/SKILL.md
diff --git a/usr/skills/default/git-workflow/SKILL.md b/skills/git-workflow/SKILL.md
similarity index 100%
rename from usr/skills/default/git-workflow/SKILL.md
rename to skills/git-workflow/SKILL.md
diff --git a/usr/skills/default/prompt-engineering/SKILL.md b/skills/prompt-engineering/SKILL.md
similarity index 100%
rename from usr/skills/default/prompt-engineering/SKILL.md
rename to skills/prompt-engineering/SKILL.md
diff --git a/usr/skills/default/security-audit/SKILL.md b/skills/security-audit/SKILL.md
similarity index 100%
rename from usr/skills/default/security-audit/SKILL.md
rename to skills/security-audit/SKILL.md
diff --git a/usr/skills/default/tdd/SKILL.md b/skills/tdd/SKILL.md
similarity index 100%
rename from usr/skills/default/tdd/SKILL.md
rename to skills/tdd/SKILL.md
diff --git a/usr/skills/custom/.gitkeep b/usr/skills/.gitkeep
similarity index 100%
rename from usr/skills/custom/.gitkeep
rename to usr/skills/.gitkeep
diff --git a/webui/index.js b/webui/index.js
index 5f184e76b..b1d68a172 100644
--- a/webui/index.js
+++ b/webui/index.js
@@ -317,7 +317,6 @@ export async function applySnapshot(snapshot, options = {}) {
if (lastLogGuid) {
const chatHistoryEl = document.getElementById("chat-history");
if (chatHistoryEl) chatHistoryEl.innerHTML = "";
- msgs.resetProcessGroups(); // Reset process groups on chat reset
lastLogVersion = 0;
lastLogGuid = snapshot.log_guid;
if (typeof onLogGuidReset === "function") {