feat: task tool: include subagent agent_id in output (#341)

This commit is contained in:
paulbettner
2025-12-22 02:21:40 -06:00
committed by GitHub
parent 1d06743c3b
commit e9a8054aba

View File

@@ -70,7 +70,16 @@ export async function task(args: TaskArgs): Promise<string> {
return `Error: ${result.error || "Subagent execution failed"}`;
}
return result.report;
// Include stable subagent metadata so orchestrators can attribute results.
// Keep the tool return type as a string for compatibility.
const header = [
`subagent_type=${subagent_type}`,
result.agentId ? `agent_id=${result.agentId}` : undefined,
]
.filter(Boolean)
.join(" ");
return `${header}\n\n${result.report}`;
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
completeSubagent(subagentId, { success: false, error: errorMessage });