Files
agent-zero/prompts/agent.system.tool.call_sub.py
Alessandro d6417657db Reduce redundant same-profile delegation
Specialists inherited an instruction to always delegate specialist work,
which could relay the same assignment through several identical agents.

Include the caller's current profile in delegation guidance and direct it
to handle matching work itself. Reserve same-profile delegation for
distinct bounded subtasks and independent reviews, preserving profile
discovery and existing child lifecycle behavior.

Validation: 157 focused tests passed. Four Default/gpt-6.1-terra live checks
confirmed single-hop root coding delegation, direct specialist execution,
and two independent same-profile reviewers.
2026-11-01 06:09:43 +01:00

31 lines
1.0 KiB
Python

from typing import Any, TYPE_CHECKING
from helpers.files import VariablesPlugin
from helpers import projects, subagents
if TYPE_CHECKING:
from agent import Agent
class CallSubordinate(VariablesPlugin):
def get_variables(
self, file: str, backup_dirs: list[str] | None = None, **kwargs
) -> dict[str, Any]:
# current agent instance
agent: Agent | None = kwargs.get("_agent", None)
# current project
project = projects.get_context_project_name(agent.context) if agent else None
# available agents in project (or global)
agents = subagents.get_available_agents_dict(project)
profiles = [
" ".join(
f"- {name} ({profile.title}): {profile.context.strip() or profile.description}".split()
)
for name, profile in agents.items()
]
return {
"current_profile": (agent.config.profile or "default") if agent else None,
"agent_profiles": "\n".join(profiles) or None,
}