






















@@ -364,6 +364,7 @@ function getLastDispatchCtx():
364364OriginatingTo?: string;
365365ParentSessionKey?: string;
366366SessionKey?: string;
367+ThreadStarterBody?: string;
367368To?: string;
368369Transcript?: string;
369370}
@@ -384,6 +385,7 @@ function getLastDispatchCtx():
384385OriginatingTo?: string;
385386ParentSessionKey?: string;
386387SessionKey?: string;
388+ThreadStarterBody?: string;
387389To?: string;
388390Transcript?: string;
389391};
@@ -1053,6 +1055,49 @@ describe("processDiscordMessage session routing", () => {
10531055});
10541056expect(getLastDispatchCtx()?.ParentSessionKey).toBeUndefined();
10551057});
1058+1059+it("omits thread starter context when the effective thread session already exists", async () => {
1060+const threadSessionKey = "agent:main:discord:channel:thread-1";
1061+readSessionUpdatedAt.mockImplementation((params?: unknown) => {
1062+const sessionKey = (params as { sessionKey?: string } | undefined)?.sessionKey;
1063+return sessionKey === threadSessionKey ? 1_700_000_000_000 : undefined;
1064+});
1065+const rest = {
1066+get: vi.fn(async () => ({
1067+content: "original thread starter",
1068+embeds: [],
1069+author: { id: "U2", username: "bob", discriminator: "0" },
1070+timestamp: new Date().toISOString(),
1071+})),
1072+};
1073+const ctx = await createBaseContext({
1074+baseSessionKey: threadSessionKey,
1075+route: BASE_CHANNEL_ROUTE,
1076+messageChannelId: "thread-1",
1077+message: {
1078+id: "m1",
1079+channelId: "thread-1",
1080+content: "follow-up",
1081+timestamp: new Date().toISOString(),
1082+attachments: [],
1083+},
1084+messageText: "follow-up",
1085+baseText: "follow-up",
1086+threadChannel: { id: "thread-1", name: "child-thread" },
1087+threadParentId: "parent-1",
1088+client: { rest },
1089+channelConfig: { allowed: true, users: ["U2"] },
1090+});
1091+1092+await runProcessDiscordMessage(ctx);
1093+1094+expect(rest.get).toHaveBeenCalled();
1095+expect(getLastDispatchCtx()).toMatchObject({
1096+SessionKey: threadSessionKey,
1097+MessageThreadId: "thread-1",
1098+});
1099+expect(getLastDispatchCtx()?.ThreadStarterBody).toBeUndefined();
1100+});
10561101});
1057110210581103describe("processDiscordMessage draft streaming", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。