feat: Enforce AgentFactory usage and improve trait inference #316
+168
−12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Enforce AgentFactory Usage and Improve Trait Inference
Summary
This PR implements mandatory AgentFactory execution for custom agents and significantly improves trait inference accuracy. The changes ensure that custom agents are properly composed with correct voice mappings and that users receive immediate feedback on invalid trait selections.
Problem Statement
Before this PR:
--traitswere merged with inferred traits, defeating precisionResult: Inconsistent agent composition, wrong voice assignments, poor user experience.
Solution Overview
This PR addresses all issues through four complementary improvements:
1. Constitutional Enforcement (SKILL.md)
Added mandatory AgentFactory execution rules at the top of the skill:
Impact: AI cannot claim to create "custom agents" without executing AgentFactory.
2. Error Recovery Protocol (SKILL.md)
Added step-by-step recovery guidance for invalid trait errors:
Impact: Users immediately see valid options instead of guessing blindly.
3. Enhanced Error Messages (AgentFactory.ts v1.1.0)
Before:
After:
Impact: Users get immediate actionable feedback without a second command.
4. Expanded Technical Keywords (Traits.yaml)
Added 20+ programming-related keywords to technical expertise:
Impact: Technical tasks now correctly infer
technicalinstead oflegalorresearch.5. Explicit Trait Recommendations (CreateCustomAgent.md)
Added Step 1.5 with clear comparison:
--traits "technical,meticulous,systematic"--task "..."(might infer wrong traits)When to use explicit traits:
Impact: Users understand when to prioritize explicit trait selection.
6. Fixed Trait Merging Bug (AgentFactory.ts)
Before (v1.0.0):
Result:
--traits "technical,pragmatic,rapid" --task "POSIX compliance"→[technical, pragmatic, rapid, legal, analytical, thorough]❌After (v1.1.0):
Result:
--traits "technical,pragmatic,rapid" --task "POSIX compliance"→[technical, pragmatic, rapid]✅Impact: Explicit traits now fully override inference as intended.
Changes Summary
SKILL.mdCreateCustomAgent.mdAgentFactory.tsTraits.yamlTotal: +180 lines, 4 files modified
Testing
Test 1: Invalid Traits Error Message
Command:
Before (v1.0.0):
After (v1.1.0):
✅ Pass: Users now see all valid options immediately.
Test 2: Trait Inference Accuracy
Command:
bun run AgentFactory.ts --task "TypeScript code development" --output summaryBefore (v1.0.0):
After (v1.1.0):
✅ Pass: Technical keywords now match technical expertise.
Test 3: Explicit Trait Override
Command:
Before (v1.0.0):
After (v1.1.0):
✅ Pass: Explicit traits fully override inference.
Breaking Changes
None. All changes are additive or improvements to existing functionality.
Migration Guide
No migration needed. Users will benefit from:
Documentation Updates
Checklist
Related Issues
Closes: #312
Notes
This PR significantly improves the custom agent creation workflow by:
The changes maintain backward compatibility while dramatically improving the user experience and correctness of agent composition.
🤖 Generated with Claude Code