Conversation
Combined Analysis & Plan - Issue #962Executive SummaryRefactor agent template loading so Handlebars expressions work in YAML frontmatter, enabling agents to declare their own swarm-vs-non-swarm defaults for Questions and Key Decisions
HIGH/CRITICAL Risks
Implementation OverviewHigh-Level Execution Phases
Quick Stats
Complete Analysis & Implementation Details (click to expand)Research FindingsProblem Space
Codebase Research
Affected FilesSource files:
Agent templates (frontmatter changes only):
Test files:
Documentation:
Integration Points
Medium Severity Risks
Implementation PlanAutomated Test Cases to CreateTest File: Click to expand test structure (12 lines)describe('template substitution in frontmatter', () => {
it('should resolve Handlebars expressions in frontmatter model field before parsing', async () => {
// Setup: agent with model: {{#if SWARM_MODE}}sonnet{{else}}opus{{/if}}
// Call loadAgents with templateVariables: { SWARM_MODE: true }
// Assert: agent model is 'sonnet'
})
it('should resolve Handlebars expressions in frontmatter effort field', async () => {
// Setup: agent with effort: {{#if SWARM_MODE}}medium{{/if}}
// Call loadAgents with templateVariables: { SWARM_MODE: true }
// Assert: agent effort is 'medium'
})
it('should resolve to non-swarm defaults when SWARM_MODE is falsy', async () => {
// Setup: agent with model: {{#if SWARM_MODE}}sonnet{{else}}opus{{/if}}
// Call loadAgents with templateVariables: {}
// Assert: agent model is 'opus'
})
it('should handle empty effort when SWARM_MODE is falsy', async () => {
// Setup: agent with effort: {{#if SWARM_MODE}}medium{{/if}}
// Call loadAgents with templateVariables: {}
// Assert: agent.effort is undefined
})
})Test File: Tests to update:
Files to Modify1.
|
Implementation CompleteSummaryRefactored agent template system to apply Handlebars template substitution before frontmatter parsing, enabling conditional expressions in YAML fields like Changes Made
Validation Results
|
Implementation Complete - Issue #962SummaryRefactored agent template loading so Handlebars expressions work in YAML frontmatter, enabling agents to declare their own swarm-vs-non-swarm defaults for Changes Made
Validation Results
Behavior ChangeUsers who set Detailed Changes by File (click to expand)Files Modifiedsrc/lib/AgentManager.tsChanges: Moved template substitution before src/lib/SwarmSetupService.tsChanges: Removed templates/agents/iloom-issue-planner.mdChanges: Added templates/agents/iloom-issue-implementer.mdChanges: Added templates/agents/iloom-issue-enhancer.mdChanges: Added templates/agents/iloom-code-reviewer.mdChanges: Added templates/agents/iloom-issue-analyzer.mdChanges: Added templates/agents/iloom-issue-analyze-and-plan.mdChanges: Added templates/agents/iloom-issue-complexity-evaluator.mdChanges: Added templates/agents/iloom-wave-verifier.mdChanges: Added static templates/agents/iloom-framework-detector.mdChanges: Added static templates/agents/CLAUDE.mdChanges: Updated YAML frontmatter format section to show Handlebars support. Replaced "Model Override Rules" with "Model and Effort Override Rules" reflecting frontmatter conditionals instead of hardcoded maps. docs/iloom-commands.mdChanges: Updated phase agent model override docs to describe frontmatter conditionals. Updated swarm effort defaults section to note values come from templates. Test Coverage Addedsrc/lib/AgentManager.test.ts
src/lib/SwarmSetupService.test.ts
Dependencies AddedNone |
2d806ad to
725e601
Compare
…swarm defaults to agent files
- Move Handlebars template substitution before frontmatter parsing in
AgentManager.loadAgents() so model/effort fields can use conditionals
- Add {{#if SWARM_MODE}} conditionals to 7 agent templates for model/effort
- Remove hardcoded defaultSwarmModels/defaultSwarmEfforts maps from SwarmSetupService
- Add static effort: high to wave-verifier and framework-detector agents
- Fix Object.assign mutation of caller's templateVariables (use local copy)
- Update tests, docs, and agent CLAUDE.md
Fixes #962
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove internal details (env var names, file paths, agent rendering mechanics, confidence thresholds, subagent_type parameters) from iloom-commands.md. Keep behavior descriptions, replace mechanisms with user-visible outcomes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move Handlebars conditional to wrap the full `effort:` key-value line instead of just the value. Prevents `effort: ` (empty value) in non-swarm mode. Updated all 7 agent templates and CLAUDE.md example. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
No reason to use low effort on a fast model (haiku). Also wrap entire effort line in conditionals when there's no else branch to avoid empty `effort: ` values in non-swarm mode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Restore swarmModel explanation and Important note in docs - Remove implementation details from user-facing docs - Change complexity-evaluator swarm effort from low to high - Wrap effort lines in full conditionals (no empty values) - Add AgentManager integration tests with real template files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2929958 to
050fac0
Compare
iloom Session SummaryKey Themes:
Session Details (click to expand)Key Insights
Decisions Made
Challenges Resolved
Lessons Learned
Generated with 🤖❤️ by iloom.ai |
Fixes #962
Refactor: Apply template substitution to agent frontmatter and extract swarm defaults to agent files
Issue details
Context
Currently in
AgentManager.loadAgents(), template variable substitution is applied only to the agent prompt body (after frontmatter parsing). This means frontmatter fields likeeffortandmodelcannot use Handlebars expressions. Additionally, swarm-specific defaults for model and effort are maintained as hardcoded maps inSwarmSetupService.ts(defaultSwarmModels,defaultSwarmEfforts), which is a non-obvious place for these defaults to live.Goal
Make agent defaults declarative by:
AgentManager.loadAgents()so frontmatter fields can use Handlebars expressionsdefaultSwarmModelsanddefaultSwarmEffortsmaps fromSwarmSetupService.tsExample
Agent templates would declare their own defaults for both modes:
Implementation
1. Move template substitution before frontmatter parsing
In
src/lib/AgentManager.ts, applysubstituteVariables()to the raw file content before callingparseMarkdownAgent():Remove the later substitution loop (currently lines ~118-124) which becomes redundant.
2. Add conditional defaults to all agent template frontmatter
Update each agent template in
templates/agents/to declare model and effort using{{#if SWARM_MODE}}conditionals, matching the current values indefaultSwarmModelsanddefaultSwarmEfforts.3. Remove hardcoded maps from SwarmSetupService
Remove
defaultSwarmModelsanddefaultSwarmEffortsmaps. The override chain becomes: user settings > agent frontmatter (which already contains the correct mode-specific defaults) > Claude Code default.Related
Follow-up from #957 (configurable effort levels) where this pattern was identified during code review.
This PR was created automatically by iloom.