Skip to content

Commit 1e11f94

Browse files
Moshe Krupperclaude
authored andcommitted
refactor(agent-to-agent): destructure payload in applyA2aMessageGate
Per review: destructure the approval payload once instead of repeating `payload.x`, and narrow `platform_id` up front so it's used directly (drops the separate `targetAgentGroupId` local). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 295377f commit 1e11f94

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/modules/agent-to-agent/message-gate.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@ import type { ApprovalHandler } from '../approvals/index.js';
88
import { performAgentRoute, type RoutableAgentMessage } from './agent-route.js';
99

1010
export const applyA2aMessageGate: ApprovalHandler = async ({ session, payload, notify }) => {
11-
const targetAgentGroupId = typeof payload.platform_id === 'string' ? payload.platform_id : '';
12-
if (!targetAgentGroupId) {
11+
const { id, platform_id, content, in_reply_to } = payload;
12+
if (typeof platform_id !== 'string' || !platform_id) {
1313
notify('Message approved but the target agent group was missing from the request.');
1414
log.warn('a2a_message_gate apply: missing target', { sessionId: session.id });
1515
return;
1616
}
1717

1818
const msg: RoutableAgentMessage = {
19-
id: typeof payload.id === 'string' ? payload.id : `a2a-gate-${Date.now()}`,
20-
platform_id: targetAgentGroupId,
21-
content: typeof payload.content === 'string' ? payload.content : '',
22-
in_reply_to: typeof payload.in_reply_to === 'string' ? payload.in_reply_to : null,
19+
id: typeof id === 'string' ? id : `a2a-gate-${Date.now()}`,
20+
platform_id,
21+
content: typeof content === 'string' ? content : '',
22+
in_reply_to: typeof in_reply_to === 'string' ? in_reply_to : null,
2323
};
2424

25-
await performAgentRoute(msg, session, targetAgentGroupId);
25+
await performAgentRoute(msg, session, platform_id);
2626
log.info('Held agent message delivered after approval', {
2727
from: session.agent_group_id,
28-
to: targetAgentGroupId,
28+
to: platform_id,
2929
msgId: msg.id,
3030
});
3131
};

0 commit comments

Comments
 (0)