Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix: surface stderr in errorOutput fallback and add `UNKNOWN_EXEC_ERROR` prefix (#14964)

Arvin Xu03c79bfb62c4
diff --git a/packages/builtin-tool-local-system/src/client/executor/index.ts b/packages/builtin-tool-local-system/src/client/executor/index.ts
index 9fd8fafa478..a38a5e8ba4f 100644
--- a/packages/builtin-tool-local-system/src/client/executor/index.ts
+++ b/packages/builtin-tool-local-system/src/client/executor/index.ts
@@ -66,7 +66,8 @@ class LocalSystemExecutor extends BaseExecutor<typeof LocalSystemApiEnum> {
}): BuiltinToolResult {
const errorMessage =
typeof output.error?.message === 'string' ? output.error.message : undefined;
- const safeContent = output.content || errorMessage || 'Tool execution failed';
+ const safeContent =
+ output.content || errorMessage || '[UNKNOWN_EXEC_ERROR] Tool execution failed';
if (!output.success) {
return {
diff --git a/packages/tool-runtime/src/ComputerRuntime.ts b/packages/tool-runtime/src/ComputerRuntime.ts
index b750af98dd0..34e85eb31e2 100644
--- a/packages/tool-runtime/src/ComputerRuntime.ts
+++ b/packages/tool-runtime/src/ComputerRuntime.ts
@@ -298,7 +298,10 @@ export abstract class ComputerRuntime {
if (!result.success) {
return this.errorOutput(result, {
error: result.error?.message,
+ exitCode: result.result?.exitCode ?? result.result?.exit_code,
isBackground: args.background || false,
+ stderr: result.result?.stderr,
+ stdout: result.result?.stdout,
success: false,
});
}
@@ -468,10 +471,19 @@ export abstract class ComputerRuntime {
// error object, JSON.stringify(undefined) returns the value `undefined`
// (not the string "undefined"), which collapsed downstream into an empty
// tool-message content while pluginState still got persisted.
+ //
+ // Priority chain:
+ // 1. result.error.message (explicit error from service layer)
+ // 2. JSON.stringify(result.error) (non-Error error objects)
+ // 3. state.stderr (e.g. git commit failure — exit ≠ 0, error in stderr)
+ // 4. state.error (runtime-level error message)
+ // 5. [UNKNOWN_EXEC_ERROR] Tool execution failed (last-resort fallback)
const errorText =
result.error?.message ||
(result.error !== undefined ? JSON.stringify(result.error) : undefined) ||
- 'Tool execution failed';
+ (typeof state?.stderr === 'string' ? state.stderr : undefined) ||
+ (typeof state?.error === 'string' ? state.error : undefined) ||
+ '[UNKNOWN_EXEC_ERROR] Tool execution failed';
return {
content: errorText,
state,