delegate_to_subagents
Delegate development tasks to specialized Goose CLI subagents, enabling autonomous execution for roles like backend, frontend, or QA engineers, with flexible parallel or sequential workflows.
Instructions
Delegate tasks to Goose CLI subagents for autonomous development
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agents | Yes | Array of subagents to create | |
| execution_mode | No | How to execute the subagents | parallel |
| task | Yes | The development task to delegate to subagents | |
| working_directory | No | Working directory for the subagents (defaults to current directory) |
Implementation Reference
- src/index.js:172-209 (handler)The main handler function that parses arguments, creates a delegation prompt, spawns Goose CLI processes for subagents, tracks the session, and returns a success message with session ID.async delegateToSubagents(args) { const { task, agents, execution_mode = 'parallel', working_directory = process.cwd() } = args; const sessionId = uuidv4(); // Ensure Goose alpha features are enabled process.env.ALPHA_FEATURES = 'true'; try { // Create the delegation prompt for Goose const delegationPrompt = this.createDelegationPrompt(task, agents, execution_mode); // Execute Goose with the delegation prompt const gooseProcess = await this.executeGoose(delegationPrompt, working_directory, sessionId); this.activeSubagents.set(sessionId, { task, agents, execution_mode, status: 'running', startTime: new Date(), process: gooseProcess }); return { content: [ { type: 'text', text: `Successfully delegated task to ${agents.length} subagents in ${execution_mode} mode.\n\nSession ID: ${sessionId}\nTask: ${task}\n\nSubagents created:\n${agents.map(agent => `- ${agent.role}: ${agent.instructions}`).join('\n')}\n\nUse get_subagent_results with session_id "${sessionId}" to retrieve results when complete.` } ] }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to delegate to subagents: ${error.message}` ); } }
- src/index.js:44-85 (schema)Defines the input schema for the delegate_to_subagents tool, including properties for task, agents array with roles and instructions, execution mode, and working directory.inputSchema: { type: 'object', properties: { task: { type: 'string', description: 'The development task to delegate to subagents' }, agents: { type: 'array', items: { type: 'object', properties: { role: { type: 'string', description: 'Agent role (e.g., backend_developer, frontend_developer, qa_engineer)' }, instructions: { type: 'string', description: 'Specific instructions for this agent' }, recipe: { type: 'string', description: 'Optional recipe name to use for this agent' } }, required: ['role', 'instructions'] }, description: 'Array of subagents to create' }, execution_mode: { type: 'string', enum: ['parallel', 'sequential'], default: 'parallel', description: 'How to execute the subagents' }, working_directory: { type: 'string', description: 'Working directory for the subagents (defaults to current directory)' } }, required: ['task', 'agents'] }
- src/index.js:41-86 (registration)Registers the delegate_to_subagents tool in the ListTools response, including name, description, and input schema.{ name: 'delegate_to_subagents', description: 'Delegate tasks to Goose CLI subagents for autonomous development', inputSchema: { type: 'object', properties: { task: { type: 'string', description: 'The development task to delegate to subagents' }, agents: { type: 'array', items: { type: 'object', properties: { role: { type: 'string', description: 'Agent role (e.g., backend_developer, frontend_developer, qa_engineer)' }, instructions: { type: 'string', description: 'Specific instructions for this agent' }, recipe: { type: 'string', description: 'Optional recipe name to use for this agent' } }, required: ['role', 'instructions'] }, description: 'Array of subagents to create' }, execution_mode: { type: 'string', enum: ['parallel', 'sequential'], default: 'parallel', description: 'How to execute the subagents' }, working_directory: { type: 'string', description: 'Working directory for the subagents (defaults to current directory)' } }, required: ['task', 'agents'] } },
- src/index.js:149-150 (registration)Dispatches calls to the delegate_to_subagents handler in the CallToolRequestHandler switch statement.case 'delegate_to_subagents': return await this.delegateToSubagents(args);
- src/index.js:211-229 (helper)Helper function to generate the prompt for delegating the task to Goose subagents based on provided agents and execution mode.createDelegationPrompt(task, agents, execution_mode) { const agentDescriptions = agents.map(agent => { let description = `${agent.role} with instructions: "${agent.instructions}"`; if (agent.recipe) { description += ` using recipe "${agent.recipe}"`; } return description; }).join(', '); const executionPhrase = execution_mode === 'parallel' ? 'in parallel simultaneously' : 'sequentially one after another'; return `Use ${agents.length} subagents working ${executionPhrase} to complete this task: "${task}". Create these specialized subagents: ${agentDescriptions}. Each subagent should work independently on their assigned part of the task. Provide a comprehensive summary of all results when complete.`; }