Skip to content

Commit 4362e1a

Browse files
authored
fix(agents): recognize nested message delivery receipts (#111012)
1 parent dc8f901 commit 4362e1a

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

src/agents/embedded-agent-message-tool-source-reply.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,24 @@ describe("isDeliveredMessagingToolResult", () => {
319319
}),
320320
).toBe(true);
321321
});
322+
323+
it("accepts a nested provider message id as delivery evidence", () => {
324+
expect(
325+
isDeliveredMessagingToolResult({
326+
toolName: "message",
327+
args: {
328+
action: "send",
329+
channel: "qa-channel",
330+
target: "qa-a2a-requester",
331+
message: "reply",
332+
},
333+
result: {
334+
content: [{ type: "text", text: '{"message":{"id":"qa-message-242"}}' }],
335+
details: { message: { id: "qa-message-242" } },
336+
},
337+
}),
338+
).toBe(true);
339+
});
322340
});
323341

324342
describe("isDeliveredMessageToolOnlySourceReplyResult", () => {

src/agents/embedded-agent-message-tool-source-reply.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,12 @@ function recordHasDeliveredMessageId(record: Record<string, unknown>): boolean {
8484
const normalized = normalizeStatus(value);
8585
return Boolean(normalized && !NON_DELIVERY_MESSAGE_IDS.has(normalized));
8686
};
87-
if (hasDeliveredId(record.messageId) || hasDeliveredId(record.pollId)) {
87+
const message = asRecord(record.message);
88+
if (
89+
hasDeliveredId(record.messageId) ||
90+
hasDeliveredId(record.pollId) ||
91+
hasDeliveredId(message.id)
92+
) {
8893
return true;
8994
}
9095
const receipt = record.receipt;

src/agents/embedded-agent-runner/run/message-tool-terminal.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@ describe("message-tool-only source replies", () => {
5454
}),
5555
expected: true,
5656
},
57+
{
58+
label: "gateway plugin send result",
59+
context: createAfterToolCallContext({
60+
toolName: "message",
61+
args: { action: "send", message: "visible reply" },
62+
result: {
63+
content: [{ type: "text", text: '{"message":{"id":"qa-message-1"}}' }],
64+
details: { message: { id: "qa-message-1" } },
65+
},
66+
}),
67+
expected: true,
68+
},
5769
{
5870
label: "hook result delivery evidence",
5971
context: createAfterToolCallContext({

0 commit comments

Comments
 (0)