From 63746dfeb3dc789fdaaf04c1b650d3ef9b116047 Mon Sep 17 00:00:00 2001 From: Koshkoshinsk Date: Tue, 14 Apr 2026 15:31:00 +0000 Subject: [PATCH] fix(v2/delivery): allow agent self-messages without a destination row Approval follow-up prompts (e.g. the post-rebuild "Packages installed, verify they work" note) are written with channel_type='agent' and platform_id=, and were dropped by the agent-to-agent authorization check because no self-destination row exists. Agents are always authorized to message themselves; skip the hasDestination check when source == target. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/delivery.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/delivery.ts b/src/delivery.ts index a2d93fae3..7889dd22e 100644 --- a/src/delivery.ts +++ b/src/delivery.ts @@ -319,7 +319,12 @@ async function deliverMessage( log.warn('Agent message missing target agent group ID', { id: msg.id }); return; } - if (!hasDestination(session.agent_group_id, 'agent', targetAgentGroupId)) { + // Self-messages are always allowed — used for system notes injected back + // into an agent's own session (e.g. post-approval follow-up prompts). + if ( + targetAgentGroupId !== session.agent_group_id && + !hasDestination(session.agent_group_id, 'agent', targetAgentGroupId) + ) { log.warn('Unauthorized agent-to-agent message — dropping', { source: session.agent_group_id, target: targetAgentGroupId,