Преглед изворни кода

Merge branch 'pr-180-latest' into master

Ma пре 7 месеци
родитељ
комит
c6e304f451
1 измењених фајлова са 31 додато и 22 уклоњено
  1. 31 22
      packages/core/src/interaction/project-tools.ts

+ 31 - 22
packages/core/src/interaction/project-tools.ts

@@ -563,30 +563,39 @@ export function createInteractionToolsFromDeps(
       const chatRequestOptions = hooks?.getChatRequestOptions?.() ?? {};
       let response: Awaited<ReturnType<typeof chatCompletion>> | undefined;
       if (instrumentedPipeline.config?.client && instrumentedPipeline.config?.model) {
-        response = await chatCompletion(
-          instrumentedPipeline.config.client,
-          instrumentedPipeline.config.model,
-          [
+        try {
+          response = await chatCompletion(
+            instrumentedPipeline.config.client,
+            instrumentedPipeline.config.model,
+            [
+              {
+                role: "system",
+                content: [
+                  "You are InkOS inside the terminal workbench.",
+                  "Respond conversationally and briefly.",
+                  "If there is no active book, help the user decide what to write next.",
+                  "If there is an active book, keep the answer grounded in that book context.",
+                ].join(" "),
+              },
+              {
+                role: "user",
+                content: `activeBook=${bookLabel}\nautomationMode=${options.automationMode}\nmessage=${input}`,
+              },
+            ],
             {
-              role: "system",
-              content: [
-                "You are InkOS inside the terminal workbench.",
-                "Respond conversationally and briefly.",
-                "If there is no active book, help the user decide what to write next.",
-                "If there is an active book, keep the answer grounded in that book context.",
-              ].join(" "),
+              temperature: chatRequestOptions.temperature ?? 0.4,
+              ...(chatRequestOptions.maxTokens !== undefined && { maxTokens: chatRequestOptions.maxTokens }),
+              onTextDelta: hooks?.onChatTextDelta,
             },
-            {
-              role: "user",
-              content: `activeBook=${bookLabel}\nautomationMode=${options.automationMode}\nmessage=${input}`,
-            },
-          ],
-          {
-            temperature: chatRequestOptions.temperature ?? 0.4,
-            ...(chatRequestOptions.maxTokens !== undefined && { maxTokens: chatRequestOptions.maxTokens }),
-            onTextDelta: hooks?.onChatTextDelta,
-          },
-        );
+          );
+        } catch (err) {
+          // Thinking models (e.g. kimi-k2.5) may return empty content for simple inputs.
+          // Only swallow empty-content errors; re-throw everything else (network, auth, etc.)
+          const msg = err instanceof Error ? err.message : "";
+          if (!msg.includes("empty") && !msg.includes("content")) {
+            throw err;
+          }
+        }
       }
 
       return {