

























@@ -213,6 +213,13 @@ function mockCallArg(
213213return call[argIndex];
214214}
215215216+function latestMockCallArg(
217+mock: { mock: { calls: ReadonlyArray<ReadonlyArray<unknown>> } },
218+argIndex = 0,
219+): unknown {
220+return mockCallArg(mock, mock.mock.calls.length - 1, argIndex);
221+}
222+216223function requireRecord(value: unknown): Record<string, unknown> {
217224if (!value || typeof value !== "object") {
218225throw new Error("expected record");
@@ -1416,13 +1423,15 @@ describe("compaction-safeguard recent-turn preservation", () => {
14161423const result = (await compactionHandler(event, mockContext)) as { cancel?: boolean };
1417142414181425expect(result.cancel).not.toBe(true);
1419-const summaryCall = mockSummarizeInStages.mock.calls.at(-1)?.[0];
1420-expect(summaryCall?.headers?.["Copilot-Integration-Id"]).toBe("vscode-chat");
1421-expect(summaryCall?.headers?.["Editor-Plugin-Version"]).toBe("copilot-chat/0.35.0");
1422-expect(summaryCall?.headers?.["Openai-Organization"]).toBe("github-copilot");
1423-expect(summaryCall?.headers?.["User-Agent"]).toBe("GitHubCopilotChat/0.26.7");
1424-expect(summaryCall?.headers?.["X-Test"]).toBe("1");
1425-expect(summaryCall?.headers?.["x-initiator"]).toBe("user");
1426+const summaryCall = latestMockCallArg(mockSummarizeInStages) as {
1427+headers?: Record<string, string>;
1428+};
1429+expect(summaryCall.headers?.["Copilot-Integration-Id"]).toBe("vscode-chat");
1430+expect(summaryCall.headers?.["Editor-Plugin-Version"]).toBe("copilot-chat/0.35.0");
1431+expect(summaryCall.headers?.["Openai-Organization"]).toBe("github-copilot");
1432+expect(summaryCall.headers?.["User-Agent"]).toBe("GitHubCopilotChat/0.26.7");
1433+expect(summaryCall.headers?.["X-Test"]).toBe("1");
1434+expect(summaryCall.headers?.["x-initiator"]).toBe("user");
14261435});
1427143614281437it("does not retry summaries unless quality guard is explicitly enabled", async () => {
@@ -1565,9 +1574,11 @@ describe("compaction-safeguard recent-turn preservation", () => {
1565157415661575expect(result.cancel).not.toBe(true);
15671576expect(mockSummarizeInStages).toHaveBeenCalledTimes(2);
1568-const secondCall = mockSummarizeInStages.mock.calls.at(1)?.[0];
1569-expect(secondCall?.customInstructions).toContain("Quality check feedback");
1570-expect(secondCall?.customInstructions).toContain("missing_section:## Decisions");
1577+const secondCall = mockCallArg(mockSummarizeInStages, 1) as {
1578+customInstructions?: string;
1579+};
1580+expect(secondCall.customInstructions).toContain("Quality check feedback");
1581+expect(secondCall.customInstructions).toContain("missing_section:## Decisions");
15711582});
1572158315731584it("does not treat preserved latest asks as satisfying overlap checks", async () => {
@@ -1652,8 +1663,10 @@ describe("compaction-safeguard recent-turn preservation", () => {
1652166316531664expect(result.cancel).not.toBe(true);
16541665expect(mockSummarizeInStages).toHaveBeenCalledTimes(2);
1655-const secondCall = mockSummarizeInStages.mock.calls.at(1)?.[0];
1656-expect(secondCall?.customInstructions).toContain("latest_user_ask_not_reflected");
1666+const secondCall = mockCallArg(mockSummarizeInStages, 1) as {
1667+customInstructions?: string;
1668+};
1669+expect(secondCall.customInstructions).toContain("latest_user_ask_not_reflected");
16571670});
1658167116591672it("preserves split-turn and recent-turn suffixes when retry fallback is capped", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。