Agent Zero AI framework
refactor(prompts): compact scoped profile routing catalog
Alessandro11d72b7b42c7
diff --git a/prompts/AGENTS.md b/prompts/AGENTS.mdindex 48891adbd..2236ae7b0 100644--- a/prompts/AGENTS.md+++ b/prompts/AGENTS.md@@ -19,6 +19,7 @@- `agent.system.main.communication.native.md` owns native function-call formatting; profiles may override it alongside the legacy communication template. Shared communication additions remain transport-neutral; the brace terminator belongs only to legacy JSON formatting.- Prompt changes can alter agent behavior; keep edits narrow and intentional.- Maintain clear separation between core behavior prompts and profile/plugin-specific customization.+- Delegation catalogs show profile IDs, titles, and context (description fallback) on separate lines; preserve project-scoped discovery.- Keep configurable capability names and usage guidance in their`agent.system.tool.*.md` prompts so tool policy removes the guidance togetherwith the capability; non-tool system fragments stay capability-neutral.diff --git a/prompts/agent.system.tool.call_sub.py b/prompts/agent.system.tool.call_sub.pyindex 964e1c999..9dbc92322 100644--- a/prompts/agent.system.tool.call_sub.py+++ b/prompts/agent.system.tool.call_sub.py@@ -1,8 +1,6 @@-import jsonfrom typing import Any, TYPE_CHECKINGfrom helpers.files import VariablesPlugin-from helpers import files, projects, subagents-from helpers.print_style import PrintStyle+from helpers import projects, subagentsif TYPE_CHECKING:from agent import Agent@@ -20,15 +18,10 @@ class CallSubordinate(VariablesPlugin):# available agents in project (or global)agents = subagents.get_available_agents_dict(project)- if agents:- profiles = {}- for name, subagent in agents.items():- profiles[name] = {- "title": subagent.title,- "description": subagent.description,- "context": subagent.context,- }- return {"agent_profiles": profiles}- else:- return {"agent_profiles": None}-+ profiles = [+ " ".join(+ f"- {name} ({profile.title}): {profile.context.strip() or profile.description}".split()+ )+ for name, profile in agents.items()+ ]+ return {"agent_profiles": "\n".join(profiles) or None}diff --git a/tests/test_prompt_catalogs.py b/tests/test_prompt_catalogs.pyindex fc6dee8b4..0fd38e7f9 100644--- a/tests/test_prompt_catalogs.py+++ b/tests/test_prompt_catalogs.py@@ -1,15 +1,42 @@import jsonimport refrom pathlib import Path+from types import SimpleNamespaceimport pytest-from helpers import skills+from helpers import files, projects, skills, subagentsROOT = Path(__file__).resolve().parents[1][email protected]("project", [None, "demo"])+def test_profile_catalog_keeps_ids_titles_scope_and_routing(monkeypatch, project):+ profiles = {+ "custom-id": SimpleNamespace(+ title="Custom Title", context="Review\ncode", description="Fallback"+ ),+ "fallback": SimpleNamespace(title="Fallback", context=" \n", description="Find facts"),+ }+ scopes = []+ monkeypatch.setattr(projects, "get_context_project_name", lambda _: project)+ monkeypatch.setattr(+ subagents, "get_available_agents_dict", lambda scope: scopes.append(scope) or profiles+ )+ agent = SimpleNamespace(context=object())+ prompt = files.read_prompt_file(+ "agent.system.tool.call_sub.md", _directories=[str(ROOT / "prompts")], _agent=agent+ )+ assert scopes == [project]+ assert "available profiles:\n- custom-id (Custom Title): Review code\n- fallback (Fallback): Find facts" in prompt+ profiles.clear()+ prompt = files.read_prompt_file(+ "agent.system.tool.call_sub.md", _directories=[str(ROOT / "prompts")], _agent=agent+ )+ assert "available profiles:" not in prompt++@pytest.mark.parametrize("path", ["plugins/_code_execution/prompts/agent.system.tool.code_exe.md","plugins/_code_execution/prompts/agent.system.tool.input.md",