fix(ci): resolve tsgo regressions and target-scoped followup dedupe
This commit is contained in:
parent
5c37d58fff
commit
868d766b9a
@ -540,6 +540,40 @@ describe("createFollowupRunner messaging tool dedupe", () => {
|
||||
expect(onBlockReply).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("reuses session-level text dedupe when prior run had repeated sends to one target", async () => {
|
||||
const onBlockReply = vi.fn(async () => {});
|
||||
const sessionEntry: SessionEntry = {
|
||||
sessionId: "session",
|
||||
updatedAt: Date.now(),
|
||||
lastMessagingToolSessionId: "session",
|
||||
lastMessagingToolSentAt: Date.now(),
|
||||
lastMessagingToolSentTexts: ["hello world!"],
|
||||
lastMessagingToolSentTargets: [
|
||||
{ tool: "message", provider: "telegram", to: "123" },
|
||||
{ tool: "message", provider: "telegram", to: "123" },
|
||||
],
|
||||
};
|
||||
const sessionStore: Record<string, SessionEntry> = { main: sessionEntry };
|
||||
|
||||
runEmbeddedPiAgentMock.mockResolvedValueOnce({
|
||||
payloads: [{ text: "hello world!" }],
|
||||
meta: {},
|
||||
});
|
||||
|
||||
const runner = createMessagingDedupeRunner(onBlockReply, {
|
||||
sessionEntry,
|
||||
sessionStore,
|
||||
sessionKey: "main",
|
||||
});
|
||||
|
||||
await runner({
|
||||
...baseQueuedRun("telegram"),
|
||||
originatingTo: "123",
|
||||
});
|
||||
|
||||
expect(onBlockReply).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("drops media URL from payload when messaging tool already sent it", async () => {
|
||||
const onBlockReply = vi.fn(async () => {});
|
||||
runEmbeddedPiAgentMock.mockResolvedValueOnce({
|
||||
|
||||
@ -344,8 +344,17 @@ export function createFollowupRunner(params: {
|
||||
originatingTo,
|
||||
accountId: originAccountId,
|
||||
});
|
||||
const uniquePreviousTargets = new Set(
|
||||
previousSentTargets.map((target) =>
|
||||
JSON.stringify({
|
||||
provider: target.provider,
|
||||
to: target.to ?? "",
|
||||
accountId: target.accountId ?? "",
|
||||
}),
|
||||
),
|
||||
);
|
||||
const canReuseSessionDedupeFingerprints =
|
||||
recentTargetMatch && previousSentTargets.length <= 1;
|
||||
recentTargetMatch && uniquePreviousTargets.size <= 1;
|
||||
|
||||
const sentTexts = [
|
||||
...(runResult.messagingToolSentTexts ?? []),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user