Browse Source

fix: more descriptive tool or subtask execution failed error (#5337)

Signed-off-by: Christian Stewart <[email protected]>
Christian Stewart 2 months ago
parent
commit
cbb591eb7d
1 changed files with 7 additions and 2 deletions
  1. 7 2
      packages/opencode/src/session/prompt.ts

+ 7 - 2
packages/opencode/src/session/prompt.ts

@@ -338,6 +338,7 @@ export namespace SessionPrompt {
             },
           },
         })) as MessageV2.ToolPart
+        let executionError: Error | undefined
         const result = await taskTool
           .execute(
             {
@@ -362,7 +363,11 @@ export namespace SessionPrompt {
               },
             },
           )
-          .catch(() => {})
+          .catch((error) => {
+            executionError = error
+            log.error("subtask execution failed", { error, agent: task.agent, description: task.description })
+            return undefined
+          })
         assistantMessage.finish = "tool-calls"
         assistantMessage.time.completed = Date.now()
         await Session.updateMessage(assistantMessage)
@@ -388,7 +393,7 @@ export namespace SessionPrompt {
             ...part,
             state: {
               status: "error",
-              error: "Tool execution failed",
+              error: executionError ? `Tool execution failed: ${executionError.message}` : "Tool execution failed",
               time: {
                 start: part.state.status === "running" ? part.state.time.start : Date.now(),
                 end: Date.now(),