Skip to content

Commit 742faf1

Browse files
committed
fix(agents): preserve source reply idempotency
1 parent 76f1555 commit 742faf1

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

src/agents/pi-embedded-subscribe.handlers.tools.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,6 +1429,7 @@ describe("messaging tool media URL tracking", () => {
14291429
status: "ok",
14301430
deliveryStatus: "sent",
14311431
sourceReplySink: "internal-ui",
1432+
idempotencyKey: "stable-source-reply",
14321433
sourceReply: {
14331434
text: "visible in tui",
14341435
mediaUrls: ["file:///tmp/reply.png"],
@@ -1444,6 +1445,7 @@ describe("messaging tool media URL tracking", () => {
14441445
text: "visible in tui",
14451446
mediaUrls: ["file:///tmp/reply.png"],
14461447
channelData: { source: "tui" },
1448+
idempotencyKey: "stable-source-reply",
14471449
},
14481450
]);
14491451
});

src/agents/pi-embedded-subscribe.handlers.tools.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,11 @@ function extractMessagingToolSourceReplyPayload(
500500
if (channelData) {
501501
payload.channelData = channelData;
502502
}
503+
const idempotencyKey =
504+
readStringField(sourceReply, "idempotencyKey") ?? readStringField(details, "idempotencyKey");
505+
if (idempotencyKey) {
506+
payload.idempotencyKey = idempotencyKey;
507+
}
503508
return Object.keys(payload).length > 0 ? payload : undefined;
504509
}
505510

0 commit comments

Comments
 (0)