Просмотр исходного кода

merge: resolve conflict with origin/master in project-tools.ts

Keep our try-catch for empty-content errors while incorporating
upstream's chat function structure.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
fanghanjun 7 месяцев назад
Родитель
Сommit
3935a52df4
1 измененных файлов с 16 добавлено и 0 удалено
  1. 16 0
      packages/core/src/__tests__/interaction-chat-tokens.test.ts

+ 16 - 0
packages/core/src/__tests__/interaction-chat-tokens.test.ts

@@ -74,6 +74,22 @@ describe("chat tool – maxTokens forwarding", () => {
     const options = mockChatCompletion.mock.calls[0]?.[3] as Record<string, unknown> | undefined;
     expect(options).toHaveProperty("maxTokens", 512);
   });
+
+  it("rethrows real chatCompletion errors instead of silently falling back", async () => {
+    mockChatCompletion.mockRejectedValueOnce(new Error("provider down"));
+
+    const tools = createInteractionToolsFromDeps(
+      fakePipeline as never,
+      fakeState as never,
+      {
+        getChatRequestOptions: () => ({ temperature: 0.7 }),
+      },
+    );
+
+    await expect(
+      tools.chat?.("你好", { bookId: "test-book", automationMode: "manual" }),
+    ).rejects.toThrow("provider down");
+  });
 });
 
 describe("developBookDraft – maxTokens not capped", () => {