From 1e5de1f284c8e2e129f4be18ffbfeaf534dc17dc Mon Sep 17 00:00:00 2001 From: thejesh23 Date: Sun, 26 Jul 2026 05:03:03 -0700 Subject: [PATCH] fix(phase-16/03): ACP audit trail was always empty docs/en.md says every agent execution produces an audit entry with the complete trajectory of tool calls in between, and the gateway wraps the execution in that trail. The demo printed 'Trajectory steps: 0' and 'Artifacts: 0'. Two causes, both needed: sendMessage fired processTask without awaiting, so it returned before the handler ran; and delegateTask ran auditRunner.run before dispatching, so structuredClone(result.trajectory) snapshotted an array the handler had not filled yet. Await the handler, and audit after dispatch. Task state: completed Artifacts: 1 Trajectory steps: 2 - Searching for React 19 documentation Tool: web_search - Extracting key findings from search results Tool: doc_analysis --- .../03-communication-protocols/code/main.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 }; }