1
0

test: update delegation tests for YAML-driven agent IDs

Old hardcoded IDs (seer, forge, echo, helm, quill) replaced with
YAML-defined IDs (orchestrator, researcher, coder, writer, memory,
experimenter). Added test that old names are explicitly rejected.
This commit is contained in:
Trip T
2026-03-14 08:40:24 -04:00
parent dc380860ba
commit 0e89caa830
7 changed files with 523 additions and 64 deletions

View File

@@ -1,8 +1,7 @@
"""Timmy's delegation tools — submit tasks and list agents.
Delegation uses the orchestrator's sub-agent system. The old swarm
task-queue was removed; delegation now records intent and returns the
target agent information.
Reads agent roster from agents.yaml via the loader module.
No hardcoded agent lists.
"""
import logging
@@ -10,15 +9,6 @@ from typing import Any
logger = logging.getLogger(__name__)
# Agents available in the current orchestrator architecture
_VALID_AGENTS: dict[str, str] = {
"seer": "research",
"forge": "code",
"echo": "memory",
"helm": "routing",
"quill": "writing",
}
def delegate_task(
agent_name: str, task_description: str, priority: str = "normal"
@@ -26,19 +16,24 @@ def delegate_task(
"""Record a delegation intent to another agent.
Args:
agent_name: Name of the agent to delegate to
agent_name: Name or ID of the agent to delegate to
task_description: What you want the agent to do
priority: Task priority - "low", "normal", "high"
Returns:
Dict with agent, status, and message
"""
from timmy.agents.loader import list_agents
agent_name = agent_name.lower().strip()
if agent_name not in _VALID_AGENTS:
# Build valid agents map from YAML config
available = {a["id"]: a["role"] for a in list_agents()}
if agent_name not in available:
return {
"success": False,
"error": f"Unknown agent: {agent_name}. Valid agents: {', '.join(sorted(_VALID_AGENTS))}",
"error": f"Unknown agent: {agent_name}. Valid agents: {', '.join(sorted(available))}",
"task_id": None,
}
@@ -54,32 +49,35 @@ def delegate_task(
"success": True,
"task_id": None,
"agent": agent_name,
"role": _VALID_AGENTS[agent_name],
"role": available[agent_name],
"status": "noted",
"message": f"Delegation to {agent_name} ({_VALID_AGENTS[agent_name]}): {task_description[:100]}",
"message": f"Delegation to {agent_name} ({available[agent_name]}): {task_description[:100]}",
}
def list_swarm_agents() -> dict[str, Any]:
"""List all available sub-agents and their roles.
Reads from agents.yaml — no hardcoded roster.
Returns:
Dict with agent list
"""
try:
from timmy.agents.timmy import _PERSONAS
from timmy.agents.loader import list_agents
agents = list_agents()
return {
"success": True,
"agents": [
{
"name": p["name"],
"id": p["agent_id"],
"role": p.get("role", ""),
"status": "available",
"capabilities": ", ".join(p.get("tools", [])),
"name": a["name"],
"id": a["id"],
"role": a["role"],
"status": a.get("status", "available"),
"capabilities": ", ".join(a.get("tools", [])),
}
for p in _PERSONAS
for a in agents
],
}
except Exception as e: