Agent Zero AI framework
Convert agent and plugin metadata/configs to YAML
frdel82aef08ae270
diff --git a/agents/agent0/_context.md b/agents/agent0/_context.mddeleted file mode 100644index ef48e78e2..000000000--- a/agents/agent0/_context.md+++ /dev/null@@ -1,4 +0,0 @@-# Agent 0-- main agent of the system-- communicates to user and delegates to subordinates-- general purpose assistant, communication skills, formatted output\ No newline at end of filediff --git a/agents/agent0/agent.json b/agents/agent0/agent.jsondeleted file mode 100644index 4fa2cb2c1..000000000--- a/agents/agent0/agent.json+++ /dev/null@@ -1,5 +0,0 @@-{- "title": "Agent 0",- "description": "Main agent of the system communicating directly with the user.",- "context": ""-}diff --git a/agents/agent0/agent.yaml b/agents/agent0/agent.yamlnew file mode 100644index 000000000..aa20770c2--- /dev/null+++ b/agents/agent0/agent.yaml@@ -0,0 +1,3 @@+title: Agent 0+description: Main agent of the system communicating directly with the user.+context: ''diff --git a/agents/default/_context.md b/agents/default/_context.mddeleted file mode 100644index 24a619beb..000000000--- a/agents/default/_context.md+++ /dev/null@@ -1,3 +0,0 @@-# Default prompts-- default prompt file templates-- should be inherited and overriden by specialized prompt profiles\ No newline at end of filediff --git a/agents/default/agent.json b/agents/default/agent.jsondeleted file mode 100644index c5c905f70..000000000--- a/agents/default/agent.json+++ /dev/null@@ -1,5 +0,0 @@-{- "title": "Default",- "description": "Default prompt file templates. Should be inherited and overriden by specialized prompt profiles.",- "context": ""-}diff --git a/agents/default/agent.yaml b/agents/default/agent.yamlnew file mode 100644index 000000000..4d3140f2e--- /dev/null+++ b/agents/default/agent.yaml@@ -0,0 +1,4 @@+title: Default+description: Default prompt file templates. Should be inherited and overriden by specialized+ prompt profiles.+context: ''diff --git a/agents/developer/_context.md b/agents/developer/_context.mddeleted file mode 100644index d1ae067e7..000000000--- a/agents/developer/_context.md+++ /dev/null@@ -1,2 +0,0 @@-# Developer-- agent specialized in complex software development\ No newline at end of filediff --git a/agents/developer/agent.json b/agents/developer/agent.jsondeleted file mode 100644index 8680176e3..000000000--- a/agents/developer/agent.json+++ /dev/null@@ -1,5 +0,0 @@-{- "title": "Developer",- "description": "Agent specialized in complex software development.",- "context": "Use this agent for software development tasks, including writing code, debugging, refactoring, and architectural design."-}diff --git a/agents/developer/agent.yaml b/agents/developer/agent.yamlnew file mode 100644index 000000000..a5c7c1df6--- /dev/null+++ b/agents/developer/agent.yaml@@ -0,0 +1,4 @@+title: Developer+description: Agent specialized in complex software development.+context: Use this agent for software development tasks, including writing code, debugging,+ refactoring, and architectural design.diff --git a/agents/hacker/_context.md b/agents/hacker/_context.mddeleted file mode 100644index 548236b72..000000000--- a/agents/hacker/_context.md+++ /dev/null@@ -1,2 +0,0 @@-# Hacker-- agent specialized in cyber security and penetration testing\ No newline at end of filediff --git a/agents/hacker/agent.json b/agents/hacker/agent.jsondeleted file mode 100644index cde645d79..000000000--- a/agents/hacker/agent.json+++ /dev/null@@ -1,5 +0,0 @@-{- "title": "Hacker",- "description": "Agent specialized in cyber security and penetration testing.",- "context": "Use this agent for cybersecurity tasks such as penetration testing, vulnerability analysis, and security auditing."-}diff --git a/agents/hacker/agent.yaml b/agents/hacker/agent.yamlnew file mode 100644index 000000000..943eaac11--- /dev/null+++ b/agents/hacker/agent.yaml@@ -0,0 +1,4 @@+title: Hacker+description: Agent specialized in cyber security and penetration testing.+context: Use this agent for cybersecurity tasks such as penetration testing, vulnerability+ analysis, and security auditing.diff --git a/agents/researcher/_context.md b/agents/researcher/_context.mddeleted file mode 100644index 3953f6cf1..000000000--- a/agents/researcher/_context.md+++ /dev/null@@ -1,2 +0,0 @@-# Researcher-- agent specialized in research, data analysis and reporting\ No newline at end of filediff --git a/agents/researcher/agent.json b/agents/researcher/agent.jsondeleted file mode 100644index e06a9639b..000000000--- a/agents/researcher/agent.json+++ /dev/null@@ -1,5 +0,0 @@-{- "title": "Researcher",- "description": "Agent specialized in research, data analysis and reporting.",- "context": "Use this agent for information gathering, data analysis, topic research, and generating comprehensive reports."-}diff --git a/agents/researcher/agent.yaml b/agents/researcher/agent.yamlnew file mode 100644index 000000000..4b4f7df42--- /dev/null+++ b/agents/researcher/agent.yaml@@ -0,0 +1,4 @@+title: Researcher+description: Agent specialized in research, data analysis and reporting.+context: Use this agent for information gathering, data analysis, topic research,+ and generating comprehensive reports.diff --git a/initialize.py b/initialize.pyindex 9b48a2684..ea8ea606d 100644--- a/initialize.py+++ b/initialize.py@@ -142,7 +142,7 @@ def initialize_preload():def initialize_migration():from python.helpers import migration, dotenv# run migration- migration.migrate_user_data()+ migration.startup_migration()# reload .env as it might have been moveddotenv.load_dotenv()# reload settings to ensure new paths are picked updiff --git a/plugins/example_agent/agents/plugin_example/agent.json b/plugins/example_agent/agents/plugin_example/agent.jsondeleted file mode 100644index 4e299f268..000000000--- a/plugins/example_agent/agents/plugin_example/agent.json+++ /dev/null@@ -1,5 +0,0 @@-{- "title": "Plugin Example Agent",- "description": "This is an example agent profile loaded from the 'example_agent' plugin.",- "context": "You are an example agent provided by the 'example_agent' plugin. Your purpose is to demonstrate how plugins can distribute agent profiles."-}diff --git a/plugins/example_agent/agents/plugin_example/agent.yaml b/plugins/example_agent/agents/plugin_example/agent.yamlnew file mode 100644index 000000000..c624990ce--- /dev/null+++ b/plugins/example_agent/agents/plugin_example/agent.yaml@@ -0,0 +1,4 @@+title: Plugin Example Agent+description: This is an example agent profile loaded from the 'example_agent' plugin.+context: You are an example agent provided by the 'example_agent' plugin. Your purpose+ is to demonstrate how plugins can distribute agent profiles.diff --git a/plugins/example_agent/plugin.json b/plugins/example_agent/plugin.jsondeleted file mode 100644index 81661b42b..000000000--- a/plugins/example_agent/plugin.json+++ /dev/null@@ -1,9 +0,0 @@-{- "title": "Example Agent",- "description": "Example agent plugin demonstrating the Agent Zero plugin system.",- "version": "1.0.0",- "settings_sections": [],- "per_project_config": true,- "per_agent_config": false,- "always_enabled": true-}diff --git a/plugins/example_agent/plugin.yaml b/plugins/example_agent/plugin.yamlnew file mode 100644index 000000000..91e828957--- /dev/null+++ b/plugins/example_agent/plugin.yaml@@ -0,0 +1,6 @@+name: Example Agent+description: Example agent plugin demonstrating the Agent Zero plugin system.+version: 1.0.0+settings_sections: []+per_project_config: true+per_agent_config: false\ No newline at end of filediff --git a/plugins/memory/config.default.json b/plugins/memory/config.default.jsondeleted file mode 100644index 13cc223b9..000000000--- a/plugins/memory/config.default.json+++ /dev/null@@ -1,18 +0,0 @@-{- "project_memory_isolation": true,- "memory_recall_enabled": true,- "memory_recall_delayed": false,- "memory_recall_interval": 3,- "memory_recall_history_len": 10000,- "memory_recall_memories_max_search": 12,- "memory_recall_solutions_max_search": 8,- "memory_recall_memories_max_result": 5,- "memory_recall_solutions_max_result": 3,- "memory_recall_similarity_threshold": 0.7,- "memory_recall_query_prep": false,- "memory_recall_post_filter": false,- "memory_memorize_enabled": true,- "memory_memorize_consolidation": true,- "memory_memorize_replace_threshold": 0.9,- "agent_memory_subdir": "default"-}diff --git a/plugins/memory/default_config.yaml b/plugins/memory/default_config.yamlnew file mode 100644index 000000000..ff0562467--- /dev/null+++ b/plugins/memory/default_config.yaml@@ -0,0 +1,16 @@+project_memory_isolation: true+memory_recall_enabled: true+memory_recall_delayed: false+memory_recall_interval: 3+memory_recall_history_len: 10000+memory_recall_memories_max_search: 12+memory_recall_solutions_max_search: 8+memory_recall_memories_max_result: 5+memory_recall_solutions_max_result: 3+memory_recall_similarity_threshold: 0.7+memory_recall_query_prep: false+memory_recall_post_filter: false+memory_memorize_enabled: true+memory_memorize_consolidation: true+memory_memorize_replace_threshold: 0.9+agent_memory_subdir: default\ No newline at end of filediff --git a/plugins/memory/extensions/python/message_loop_prompts_after/_50_recall_memories.py b/plugins/memory/extensions/python/message_loop_prompts_after/_50_recall_memories.pyindex e52cf1c70..ab8ec6ac2 100644--- a/plugins/memory/extensions/python/message_loop_prompts_after/_50_recall_memories.py+++ b/plugins/memory/extensions/python/message_loop_prompts_after/_50_recall_memories.py@@ -25,11 +25,13 @@ class RecallMemories(Extension):async def execute(self, loop_data: LoopData = LoopData(), **kwargs):- set = plugins.get_plugin_config("memory")+ set = plugins.get_plugin_config("memory", self.agent)+ if not set:+ return None# turned off in settings?if not set["memory_recall_enabled"]:- return+ return None# every X iterations (or the first one) recall memoriesif loop_data.iteration % set["memory_recall_interval"] == 0:@@ -63,7 +65,9 @@ class RecallMemories(Extension):del extras["solutions"]- set = plugins.get_plugin_config("memory")+ set = plugins.get_plugin_config("memory", self.agent)+ if not set:+ return None# try:# get system message and chat history for util llmdiff --git a/plugins/memory/extensions/python/message_loop_prompts_after/_91_recall_wait.py b/plugins/memory/extensions/python/message_loop_prompts_after/_91_recall_wait.pyindex 9039fefd0..45965a222 100644--- a/plugins/memory/extensions/python/message_loop_prompts_after/_91_recall_wait.py+++ b/plugins/memory/extensions/python/message_loop_prompts_after/_91_recall_wait.py@@ -6,7 +6,9 @@ from python.helpers import pluginsclass RecallWait(Extension):async def execute(self, loop_data: LoopData = LoopData(), **kwargs):- set = plugins.get_plugin_config("memory")+ set = plugins.get_plugin_config("memory", self.agent)+ if not set:+ return Nonetask = self.agent.get_data(DATA_NAME_TASK_MEMORIES)iter = self.agent.get_data(DATA_NAME_ITER_MEMORIES) or 0diff --git a/plugins/memory/extensions/python/monologue_end/_50_memorize_fragments.py b/plugins/memory/extensions/python/monologue_end/_50_memorize_fragments.pyindex 5fcf3227e..391cf4104 100644--- a/plugins/memory/extensions/python/monologue_end/_50_memorize_fragments.py+++ b/plugins/memory/extensions/python/monologue_end/_50_memorize_fragments.py@@ -16,7 +16,9 @@ class MemorizeMemories(Extension):async def execute(self, loop_data: LoopData = LoopData(), **kwargs):# try:- set = plugins.get_plugin_config("memory")+ set = plugins.get_plugin_config("memory", self.agent)+ if not set:+ return Noneif not set["memory_memorize_enabled"]:return@@ -36,7 +38,9 @@ class MemorizeMemories(Extension):async def memorize(self, loop_data: LoopData, log_item: LogItem, **kwargs):try:- set = plugins.get_plugin_config("memory")+ set = plugins.get_plugin_config("memory", self.agent)+ if not set:+ return Nonedb = await Memory.get(self.agent)diff --git a/plugins/memory/extensions/python/monologue_end/_51_memorize_solutions.py b/plugins/memory/extensions/python/monologue_end/_51_memorize_solutions.pyindex 82877d3c9..aeef9ea1c 100644--- a/plugins/memory/extensions/python/monologue_end/_51_memorize_solutions.py+++ b/plugins/memory/extensions/python/monologue_end/_51_memorize_solutions.py@@ -15,7 +15,9 @@ class MemorizeSolutions(Extension):async def execute(self, loop_data: LoopData = LoopData(), **kwargs):# try:- set = plugins.get_plugin_config("memory")+ set = plugins.get_plugin_config("memory", self.agent)+ if not set:+ return Noneif not set["memory_memorize_enabled"]:return@@ -34,7 +36,10 @@ class MemorizeSolutions(Extension):async def memorize(self, loop_data: LoopData, log_item: LogItem, **kwargs):try:- set = plugins.get_plugin_config("memory")+ set = plugins.get_plugin_config("memory", self.agent)+ if not set:+ return None+db = await Memory.get(self.agent)diff --git a/plugins/memory/plugin.json b/plugins/memory/plugin.jsondeleted file mode 100644index 0afa0fbc1..000000000--- a/plugins/memory/plugin.json+++ /dev/null@@ -1,8 +0,0 @@-{- "title": "Memory",- "description": "Provides persistent memory capabilities to Agent Zero agents.",- "version": "1.0.0",- "settings_sections": ["agent"],- "per_project_config": true,- "per_agent_config": false-}diff --git a/plugins/memory/plugin.yaml b/plugins/memory/plugin.yamlnew file mode 100644index 000000000..3c43c4a29--- /dev/null+++ b/plugins/memory/plugin.yaml@@ -0,0 +1,7 @@+name: Memory+description: Provides persistent memory capabilities to Agent Zero agents.+version: 1.0.0+settings_sections:+ - agent+per_project_config: true+per_agent_config: false\ No newline at end of filediff --git a/python/helpers/files.py b/python/helpers/files.pyindex de04b65ef..4a2f6ff84 100644--- a/python/helpers/files.py+++ b/python/helpers/files.py@@ -3,19 +3,16 @@ from fnmatch import fnmatchimport jsonfrom ntpath import isabsimport os-import sysimport reimport base64import shutilimport tempfilefrom typing import Any, Literalimport zipfile-import importlib-import importlib.util-import inspectimport globimport mimetypesfrom simpleeval import simple_eval+from python.helpers import yamlAGENTS_DIR = "agents"PLUGINS_DIR = "plugins"@@ -224,6 +221,12 @@ def read_file_json(relative_path: str, encoding="utf-8"):with open(absolute_path, "r", encoding=encoding) as f:return json.load(f)+def read_file_yaml(relative_path: str, encoding="utf-8"):+ absolute_path = get_abs_path(relative_path)++ with open(absolute_path, "r", encoding=encoding) as f:+ return yaml.loads(f.read())+def read_file_bin(relative_path: str):# Try to get the absolute path for the file from the original directory or backup directoriesabsolute_path = get_abs_path(relative_path)diff --git a/python/helpers/migration.py b/python/helpers/migration.pyindex 498398c15..d523411e7 100644--- a/python/helpers/migration.py+++ b/python/helpers/migration.py@@ -1,7 +1,15 @@import os+import jsonfrom python.helpers import files+from python.helpers import subagents+from python.helpers import yaml as yaml_helperfrom python.helpers.print_style import PrintStyle++def startup_migration() -> None:+ migrate_user_data()+ convert_agents_json_yaml()+def migrate_user_data() -> None:"""Migrate user data from /tmp and other locations to /usr.@@ -44,6 +52,26 @@ def migrate_user_data() -> None:PrintStyle().print("Migration check complete.")++def convert_agents_json_yaml() -> None:+ for root in subagents.get_agents_roots():+ rel_root = files.deabsolute_path(root)+ for subdir in files.get_subdirectories(rel_root):+ agent_yaml = os.path.join(rel_root, subdir, "agent.yaml")+ if files.exists(agent_yaml):+ continue++ agent_json = os.path.join(rel_root, subdir, "agent.json")+ if not files.exists(agent_json):+ continue++ try:+ agent_obj = json.loads(files.read_file(agent_json))+ files.write_file(agent_yaml, yaml_helper.dumps(agent_obj))+ except Exception as e:+ PrintStyle.error(f"Failed to convert {agent_json} to YAML", e)+ continue+# --- Helper Functions ----------------------------------------------------------def _move_dir(src: str, dst: str, overwrite: bool = False) -> None:diff --git a/python/helpers/subagents.py b/python/helpers/subagents.pyindex 54b3b2cc1..6690d59ad 100644--- a/python/helpers/subagents.py+++ b/python/helpers/subagents.py@@ -1,4 +1,5 @@from python.helpers import files+from python.helpers import yaml as yaml_helperfrom typing import TypedDict, TYPE_CHECKINGfrom pydantic import BaseModel, model_validatorimport json@@ -88,8 +89,13 @@ def _get_agents_list_from_dir(dir: str, origin: Origin) -> dict[str, SubAgentLisfor subdir in subdirs:try:- agent_json = files.read_file(files.get_abs_path(dir, subdir, "agent.json"))- agent_data = SubAgentListItem.model_validate_json(agent_json)+ agent_yaml_path = files.get_abs_path(dir, subdir, "agent.yaml")+ if files.exists(agent_yaml_path):+ agent_yaml = files.read_file(agent_yaml_path)+ agent_data = SubAgentListItem.model_validate(yaml_helper.loads(agent_yaml) or {})+ else:+ agent_json = files.read_file(files.get_abs_path(dir, subdir, "agent.json"))+ agent_data = SubAgentListItem.model_validate_json(agent_json)name = agent_data.name or subdiragent_data.name = nameagent_data.path = files.get_abs_path(dir, subdir)@@ -176,8 +182,13 @@ def delete_agent_data(name: str) -> None:def _load_agent_data_from_dir(dir: str, name: str, origin: Origin) -> SubAgent | None:try:- subagent_json = files.read_file(files.get_abs_path(dir, name, "agent.json"))- subagent = SubAgent.model_validate_json(subagent_json)+ agent_yaml_path = files.get_abs_path(dir, name, "agent.yaml")+ if files.exists(agent_yaml_path):+ agent_yaml = files.read_file(agent_yaml_path)+ subagent = SubAgent.model_validate(yaml_helper.loads(agent_yaml) or {})+ else:+ subagent_json = files.read_file(files.get_abs_path(dir, name, "agent.json"))+ subagent = SubAgent.model_validate_json(subagent_json)except Exception:# backward compatibility (before agent.json existed)try:diff --git a/python/helpers/yaml.py b/python/helpers/yaml.pynew file mode 100644index 000000000..13b1d8c55--- /dev/null+++ b/python/helpers/yaml.py@@ -0,0 +1,24 @@+import json+import yaml+++def loads(text: str):+ return yaml.safe_load(text)+++def dumps(obj, **kwargs) -> str:+ dump_kwargs = {+ "allow_unicode": True,+ "sort_keys": False,+ **kwargs,+ }+ return yaml.safe_dump(obj, **dump_kwargs)+++def from_json(text: str, **yaml_dump_kwargs) -> str:+ return dumps(json.loads(text), **yaml_dump_kwargs)+++def to_json(text: str, **json_dump_kwargs) -> str:+ obj = loads(text)+ return json.dumps(obj, ensure_ascii=False, **json_dump_kwargs)