
















@@ -309,64 +309,6 @@ describe("compactEmbeddedPiSessionDirect hooks", () => {
309309);
310310});
311311312-it("uses the session model fallback chain when implicit compaction fails", async () => {
313-resolveModelMock.mockImplementation((provider = "openai", modelId = "fake") => ({
314-model: { provider, api: "responses", id: modelId, input: [] },
315-error: null,
316-authStorage: { setRuntimeApiKey: vi.fn() },
317-modelRegistry: {},
318-}));
319-sessionCompactImpl
320-.mockRejectedValueOnce(
321-Object.assign(
322-new Error(
323-"400 The response was filtered due to the prompt triggering Azure OpenAI's content management policy.",
324-),
325-{ status: 400 },
326-),
327-)
328-.mockResolvedValueOnce({
329-summary: "fallback summary",
330-firstKeptEntryId: "entry-fallback",
331-tokensBefore: 120,
332-details: { ok: true },
333-});
334-335-const result = await compactEmbeddedPiSessionDirect({
336-sessionId: "session-1",
337-sessionKey: TEST_SESSION_KEY,
338-sessionFile: "/tmp/session.jsonl",
339-workspaceDir: "/tmp/workspace",
340-provider: "openai",
341-model: "gpt-primary",
342-config: {
343-agents: {
344-defaults: {
345-model: {
346-primary: "openai/gpt-primary",
347-fallbacks: ["anthropic/claude-fallback"],
348-},
349-},
350-},
351-} as never,
352-});
353-354-expect(result.ok).toBe(true);
355-expect(result.result?.summary).toBe("fallback summary");
356-expect(resolveModelMock).toHaveBeenCalledWith(
357-"openai",
358-"gpt-primary",
359-expect.any(String),
360-expect.anything(),
361-);
362-expect(resolveModelMock).toHaveBeenCalledWith(
363-"anthropic",
364-"claude-fallback",
365-expect.any(String),
366-expect.anything(),
367-);
368-});
369-370312it("uses the session model fallback chain when overflow compaction fails", async () => {
371313resolveModelMock.mockImplementation((provider = "openai", modelId = "fake") => ({
372314model: { provider, api: "responses", id: modelId, input: [] },
@@ -471,6 +413,19 @@ describe("compactEmbeddedPiSessionDirect hooks", () => {
471413});
472414473415expect(result.ok).toBe(true);
416+expect(result.result?.summary).toBe("fallback summary");
417+expect(resolveModelMock).toHaveBeenCalledWith(
418+"openai",
419+"gpt-primary",
420+expect.any(String),
421+expect.anything(),
422+);
423+expect(resolveModelMock).toHaveBeenCalledWith(
424+"anthropic",
425+"claude-fallback",
426+expect.any(String),
427+expect.anything(),
428+);
474429expect(config).toEqual(configBefore);
475430});
476431此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。