fix: add <available_agent_types> to all workflows spawning named agents

PR #1139 added <available_agent_types> sections to execute-phase.md and
plan-phase.md to prevent /clear from causing silent fallback to
general-purpose. However, 14 other workflows and 2 commands that also
spawn named GSD agents were missed, leaving them vulnerable to the same
regression after /clear.

Added <available_agent_types> listing to: research-phase, quick,
audit-milestone, diagnose-issues, discuss-phase-assumptions,
execute-plan, map-codebase, new-milestone, new-project, ui-phase,
ui-review, validate-phase, verify-work (workflows) and debug,
research-phase (commands).

Added regression test that enforces every workflow/command spawning
named subagent_type must have a matching <available_agent_types>
section listing all spawned types.

Fixes #1357

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-03-24 13:17:18 -04:00
parent 763c6cc642
commit 0ce31ae882
16 changed files with 131 additions and 0 deletions

View File

@@ -152,6 +152,52 @@ describe('SPAWN: spawn type consistency', () => {
);
});
test('workflows spawning named agents have <available_agent_types> listing (#1357)', () => {
// After /clear, Claude Code re-reads workflow instructions but loses agent
// context. Without an <available_agent_types> section, the orchestrator may
// fall back to general-purpose, silently breaking agent capabilities.
// PR #1139 added this to plan-phase and execute-phase but missed all other
// workflows that spawn named GSD agents.
const dirs = [WORKFLOWS_DIR, COMMANDS_DIR];
for (const dir of dirs) {
if (!fs.existsSync(dir)) continue;
const files = fs.readdirSync(dir).filter(f => f.endsWith('.md'));
for (const file of files) {
const content = fs.readFileSync(path.join(dir, file), 'utf-8');
// Find all named subagent_type references (excluding general-purpose)
const matches = [...content.matchAll(/subagent_type="([^"]+)"/g)];
const namedAgents = matches
.map(m => m[1])
.filter(t => t !== 'general-purpose');
if (namedAgents.length === 0) continue;
// Workflow spawns named agents — must have <available_agent_types>
assert.ok(
content.includes('<available_agent_types>'),
`${file} spawns named agents (${[...new Set(namedAgents)].join(', ')}) ` +
`but has no <available_agent_types> section — after /clear, the ` +
`orchestrator may fall back to general-purpose (#1357)`
);
// Every spawned agent type must appear in the listing
for (const agent of new Set(namedAgents)) {
const agentTypesMatch = content.match(
/<available_agent_types>([\s\S]*?)<\/available_agent_types>/
);
assert.ok(
agentTypesMatch,
`${file} has malformed <available_agent_types> section`
);
assert.ok(
agentTypesMatch[1].includes(agent),
`${file} spawns ${agent} but does not list it in <available_agent_types>`
);
}
}
}
});
test('execute-phase has Copilot sequential fallback in runtime_compatibility', () => {
const content = fs.readFileSync(
path.join(WORKFLOWS_DIR, 'execute-phase.md'), 'utf-8'