Skip to content

Commit 0c4d94a

Browse files
committed
fix: improve taskId error handling and documentation for delegate_task_to_agent
1 parent 2b84d03 commit 0c4d94a

3 files changed

Lines changed: 22 additions & 9 deletions

File tree

src/core/mcp/mcp-tool-executor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,11 +359,11 @@ export function getMcpToolDefinitions(toolMode: ToolMode = "essential") {
359359
},
360360
{
361361
name: "delegate_task_to_agent",
362-
description: "Delegate a task to a new agent by spawning a real process. Use specialist='CRAFTER' for implementation, specialist='GATE' for verification, specialist='DEVELOPER' for solo plan+implement.",
362+
description: "Delegate a task to a new agent by spawning a real process. Use specialist='CRAFTER' for implementation, specialist='GATE' for verification, specialist='DEVELOPER' for solo plan+implement. IMPORTANT: taskId must be a UUID from create_task (e.g., 'dda97509-b414-4c50-9835-73a1ec2f...'), NOT a task name. First call create_task to create the task and get a UUID.",
363363
inputSchema: {
364364
type: "object",
365365
properties: {
366-
taskId: { type: "string", description: "Task ID to delegate" },
366+
taskId: { type: "string", description: "UUID of the task to delegate (MUST be a UUID from create_task, NOT a task name)" },
367367
callerAgentId: { type: "string", description: "Your agent ID" },
368368
callerSessionId: { type: "string", description: "Your session ID (optional)" },
369369
specialist: { type: "string", enum: ["CRAFTER", "GATE", "DEVELOPER", "crafter", "gate", "developer"], description: "Agent type to create" },

src/core/mcp/routa-mcp-tool-manager.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,13 @@ export class RoutaMcpToolManager {
225225
"delegate_task_to_agent",
226226
`Delegate a task to a new agent by spawning a real agent process. This is the primary way to delegate work.
227227
Use specialist="CRAFTER" for implementation tasks and specialist="GATE" for verification tasks.
228-
The agent will start working immediately and you'll be notified when it completes.`,
228+
The agent will start working immediately and you'll be notified when it completes.
229+
230+
IMPORTANT: The taskId parameter must be a UUID returned by create_task (e.g., "dda97509-b414-4c50-9835-73a1ec2f...").
231+
Do NOT use task names or @@@task identifiers. First call create_task to create the task and get a UUID, then use that UUID here.
232+
You can also use convert_task_blocks to convert @@@task blocks into tasks, or list_tasks to see existing tasks with their UUIDs.`,
229233
{
230-
taskId: z.string().describe("ID of the task to delegate (from create_task)"),
234+
taskId: z.string().describe("UUID of the task to delegate (MUST be a UUID from create_task, NOT a task name)"),
231235
callerAgentId: z.string().describe("Your agent ID (the coordinator's agent ID)"),
232236
callerSessionId: z.string().optional().describe("Your session ID (if known)"),
233237
specialist: z.enum(["CRAFTER", "GATE", "DEVELOPER", "crafter", "gate", "developer"]).describe("Specialist type: CRAFTER for implementation, GATE for verification, DEVELOPER for solo plan+implement"),
@@ -324,11 +328,12 @@ The agent will start working immediately and you'll be notified when it complete
324328
private registerDelegateTask(server: McpServer) {
325329
server.tool(
326330
"delegate_task",
327-
"Assign a task to an agent and activate it. The agent will begin working on the task.",
331+
`Assign a task to an existing agent and activate it. The agent will begin working on the task.
332+
Note: taskId must be a UUID from create_task, not a task name.`,
328333
{
329-
agentId: z.string().describe("ID of the agent to delegate to"),
330-
taskId: z.string().describe("ID of the task to delegate"),
331-
callerAgentId: z.string().describe("ID of the calling agent"),
334+
agentId: z.string().describe("UUID of the agent to delegate to"),
335+
taskId: z.string().describe("UUID of the task to delegate (from create_task, NOT a task name)"),
336+
callerAgentId: z.string().describe("UUID of the calling agent"),
332337
},
333338
async (params) => {
334339
const result = await this.tools.delegate(params);

src/core/tools/agent-tools.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,15 @@ export class AgentTools {
224224

225225
const task = await this.taskStore.get(taskId);
226226
if (!task) {
227-
return errorResult(`Task not found: ${taskId}`);
227+
// Check if the taskId looks like a name instead of a UUID
228+
const looksLikeUuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(taskId);
229+
const hint = looksLikeUuid
230+
? `Use list_tasks to see available tasks, or create_task to create a new one.`
231+
: `The taskId "${taskId}" looks like a task name, not a UUID. ` +
232+
`You must use the UUID returned by create_task. ` +
233+
`First call create_task to create tasks, then use the returned taskId (UUID format). ` +
234+
`Or use list_tasks to see existing tasks.`;
235+
return errorResult(`Task not found: ${taskId}. ${hint}`);
228236
}
229237

230238
// Assign and activate

0 commit comments

Comments
 (0)