feat(agents): add named agents with AgentFactory integration for consistent agent triggering
This PR needs slightly adjustments if #322 gets merged first.
Summary
- Introduces three persistent named agents (The Engineer, The Architect, The Intern) with backstories and personality traits
- Integrates named agents into AgentFactory CLI for consistent triggering behavior
- Adds role-based agent selection for semantic task routing
- Maintains backward compatibility with existing dynamic trait composition
The Problem
Named agents existed in concept but didn't trigger consistently.
The previous implementation had named agent definitions scattered across documentation, but lacked the critical integration with AgentFactory that custom/dynamic agents had. This meant:
| Agent Type | Before | After |
|---|---|---|
| Custom Agents | AgentFactory.ts --traits "..." → JSON output → Task() |
Same (unchanged) |
| Named Agents | Manual prompt composition, no factory support | AgentFactory.ts --named engineer → JSON output → Task() |
Custom agents followed a disciplined workflow:
- Run
AgentFactory.tswith traits - Get structured JSON output (prompt, voice_id, model)
- Pass to
Task()withsubagent_type: "general-purpose"
Named agents had no equivalent path, leading to:
- Inconsistent prompt generation
- No voice mapping integration
- Manual agent selection without role-based routing
- Bypassing the constitutional rule that ALL agents must go through AgentFactory
The Solution
Named agents now use the same AgentFactory workflow as custom agents.
New CLI Parameters
# Named agent by key
bun run AgentFactory.ts --named engineer --task "Implement feature" --output json
# Named agent by role (semantic selection)
bun run AgentFactory.ts --role implementer --task "Build API" --output json
# List available named agents and roles
bun run AgentFactory.ts --list-named
Named Agent Definitions
| Agent | Key | Model | Use For |
|---|---|---|---|
| The Engineer | engineer |
sonnet | Implementation, code quality, technical decisions |
| The Architect | architect |
opus | Design review, spec compliance, strategic vision |
| The Intern | intern |
haiku | Grunt work, simple tasks, quick wins |
Role Mappings
Semantic role names automatically resolve to the appropriate named agent:
| Role | Maps To |
|---|---|
implementer, developer, coder |
The Engineer |
spec_reviewer, architecture, design, planner |
The Architect |
code_quality_reviewer, quality, reviewer |
The Engineer |
grunt_work, simple_task, quick_task |
The Intern |
Changes
New Files
| File | Purpose |
|---|---|
Data/NamedAgents.yaml |
Named agent definitions (backstories, traits, communication styles) |
Templates/NamedAgent.hbs |
Handlebars template for named agent prompt generation |
Modified Files
| File | Changes |
|---|---|
Tools/AgentFactory.ts |
Added --named, --role, --list-named support; NamedAgentDefinition interface |
SKILL.md |
Updated routing documentation for named agents |
README.md |
Added Named Agents section, role mappings, updated changelog |
INSTALL.md |
Added new files to installation steps |
Deleted Files
| File | Reason |
|---|---|
AgentPersonalities.md |
Redundant with NamedAgents.yaml (single source of truth) |
Test Plan
- [x]
--list-namedshows all three agents with roles - [x]
--named engineergenerates valid prompt with correct model (sonnet) - [x]
--named architectgenerates valid prompt with correct model (opus) - [x]
--named interngenerates valid prompt with correct model (haiku) - [x]
--role implementercorrectly resolves to engineer - [x]
--role spec_reviewercorrectly resolves to architect - [x]
--traits "security,skeptical,thorough"still works (backward compatibility) - [x] Response format uses
[AGENT:engineer]tag for voice integration - [x] All JSON output includes prompt, voice_id, and model fields
Migration
No breaking changes. Existing --traits usage continues to work.
New capability: Use --named or --role for persistent agent identities instead of ad-hoc trait composition.
🤖 Generated with Claude Code