fix(agents): instruct executor/planner to use available MCP tools (#1603)

* fix(agents): explicitly instruct agents to use available MCP tools

GSD executor and planner agents were not mentioning available MCP servers
in their task instructions, causing subagents to skip Context7 and other
configured MCP tools even when available.

Closes #1388

* fix(tests): make copilot executor tool assertion dynamic

Hardcoded tools: ['read', 'edit', 'execute', 'search'] assertion broke
when mcp__context7__* was added to gsd-executor.md frontmatter. Replace
with per-tool presence checks so adding new tools never breaks the test.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-04-03 12:48:10 -04:00
committed by GitHub
parent 5f3d4e6127
commit 0a9ce8c975
4 changed files with 59 additions and 4 deletions

View File

@@ -709,9 +709,17 @@ describe('Copilot agent conversion - real files', () => {
const result = convertClaudeAgentToCopilotAgent(content);
assert.ok(result.startsWith('---\nname: gsd-executor\n'), 'starts with correct name');
// 6 Claude tools (Read, Write, Edit, Bash, Grep, Glob) → 4 after dedup
assert.ok(result.includes("tools: ['read', 'edit', 'execute', 'search']"),
'tools mapped and deduplicated (6→4)');
// Verify deduplication happened and core tools are present (not hardcoded exact list)
const toolsLine = result.split('\n').find(l => l.startsWith('tools:'));
assert.ok(toolsLine, 'tools line present in converted output');
assert.ok(toolsLine.includes("'read'"), 'Read mapped to read');
assert.ok(toolsLine.includes("'edit'"), 'Write/Edit deduplicated to edit');
assert.ok(toolsLine.includes("'execute'"), 'Bash mapped to execute');
assert.ok(toolsLine.includes("'search'"), 'Grep/Glob deduplicated to search');
// Input tools count > output tools count (deduplication occurred)
const inputTools = content.match(/^tools:\s*\[([^\]]+)\]/m)?.[1].split(',').length ?? 0;
const outputTools = toolsLine.replace(/^tools:\s*\[/, '').replace(/\].*$/, '').split(',').length;
assert.ok(inputTools === 0 || outputTools <= inputTools, 'deduplication reduced or preserved tool count');
assert.ok(result.includes('color: yellow'), 'color preserved');
assert.ok(!result.includes('~/.claude/'), 'no ~/.claude/ in body');
});

View File

@@ -0,0 +1,33 @@
const { test, describe } = require('node:test');
const assert = require('node:assert');
const fs = require('fs');
const path = require('path');
describe('MCP tool usage in GSD agents', () => {
const agentFiles = [
path.join(__dirname, '..', 'agents', 'gsd-executor.md'),
path.join(__dirname, '..', 'agents', 'gsd-planner.md'),
];
for (const agentFile of agentFiles) {
const name = path.basename(agentFile);
test(`${name} mentions MCP tool usage`, () => {
const content = fs.readFileSync(agentFile, 'utf-8');
const hasMcpGuidance =
content.toLowerCase().includes('mcp') ||
content.includes('context7') ||
content.includes('available tools') ||
content.includes('MCP tool');
assert.ok(hasMcpGuidance, `${name} should mention MCP tool availability/usage`);
});
}
test('gsd-executor.md explicitly instructs to use available MCP tools', () => {
const content = fs.readFileSync(agentFiles[0], 'utf-8');
assert.ok(
content.includes('MCP') || content.includes('mcp__'),
'executor should reference MCP tools'
);
});
});