diff --git a/phases/16-multi-agent-and-swarms/03-communication-protocols/code/main.ts b/phases/16-multi-agent-and-swarms/03-communication-protocols/code/main.ts index 33d313571e..24c5f0ed2c 100644 --- a/phases/16-multi-agent-and-swarms/03-communication-protocols/code/main.ts +++ b/phases/16-multi-agent-and-swarms/03-communication-protocols/code/main.ts @@ -182,7 +182,7 @@ class TaskManager { task.history.push(message); task.status = { state: "submitted", timestamp: Date.now() }; - this.processTask(task, handler, message).catch((err) => { + await this.processTask(task, handler, message).catch((err) => { task.status = { state: "failed", timestamp: Date.now(), @@ -516,12 +516,12 @@ class ProtocolGateway { return { error: `Agent ${targetAgent} not found in registry` }; } + const task = await this.taskManager.sendMessage(targetAgent, message); const audit = await this.auditRunner.run( targetAgent, [message], sessionId ); - const task = await this.taskManager.sendMessage(targetAgent, message); return { task, audit }; }