فهرست منبع

fix: only keep aborted messages if they have sufficient parts (#2651)

Aiden Cline 5 ماه پیش
والد
کامیت
ff6a93f355
1فایلهای تغییر یافته به همراه13 افزوده شده و 3 حذف شده
  1. 13 3
      packages/opencode/src/session/prompt.ts

+ 13 - 3
packages/opencode/src/session/prompt.ts

@@ -281,9 +281,19 @@ export namespace SessionPrompt {
             }),
             }),
           ),
           ),
           ...MessageV2.toModelMessage(
           ...MessageV2.toModelMessage(
-            msgs.filter(
-              (m) => !(m.info.role === "assistant" && m.info.error && !MessageV2.AbortedError.isInstance(m.info.error)),
-            ),
+            msgs.filter((m) => {
+              if (m.info.role !== "assistant" || m.info.error === undefined) {
+                return true
+              }
+              if (
+                MessageV2.AbortedError.isInstance(m.info.error) &&
+                m.parts.some((part) => part.type !== "step-start" && part.type !== "reasoning")
+              ) {
+                return true
+              }
+
+              return false
+            }),
           ),
           ),
         ],
         ],
         tools: model.info.tool_call === false ? undefined : tools,
         tools: model.info.tool_call === false ? undefined : tools,