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: treat isolated worker terminal results as sucess when execution dispatched (#16324)

Rylan Cai6e790cd54d2a
diff --git a/apps/cli/src/tools/isolatedWorker.test.ts b/apps/cli/src/tools/isolatedWorker.test.ts
index 791d58e270b..68b0d28e5a9 100644
--- a/apps/cli/src/tools/isolatedWorker.test.ts
+++ b/apps/cli/src/tools/isolatedWorker.test.ts
@@ -46,9 +46,9 @@ describe('executeToolCallInWorker', () => {
const result = await executeToolCallInWorker('searchFiles', '{"keywords":""}');
expect(result).toEqual({
- content: '',
- error: 'Isolated tool worker failed for searchFiles with exit code 1: worker stderr',
- success: false,
+ content: 'Isolated tool worker failed for searchFiles with exit code 1: worker stderr',
+ state: { failureType: 'worker_exit', success: false },
+ success: true,
});
});
@@ -77,9 +77,9 @@ describe('executeToolCallInWorker', () => {
const result = await executeToolCallInWorker('globFiles', '{"pattern":"*.ts"}');
expect(result).toEqual({
- content: '',
- error: 'Isolated tool worker failed for globFiles with exit code 1: No Output',
- success: false,
+ content: 'Isolated tool worker failed for globFiles with exit code 1: No Output',
+ state: { failureType: 'worker_exit', success: false },
+ success: true,
});
});
@@ -108,9 +108,10 @@ describe('executeToolCallInWorker', () => {
const { executeToolCallInWorker } = await import('./isolatedWorker');
const result = await executeToolCallInWorker('listFiles', '{"path":"/tmp"}');
- expect(result.success).toBe(false);
- expect(result.error).toContain('Isolated tool worker returned invalid JSON for listFiles:');
- expect(result.error).toContain('Output: not-json');
+ expect(result.success).toBe(true);
+ expect(result.content).toContain('Isolated tool worker returned invalid JSON for listFiles:');
+ expect(result.content).toContain('Output: not-json');
+ expect(result.state).toEqual({ failureType: 'invalid_json', success: false });
});
it('should timeout and kill the worker when it exceeds the timeout', async () => {
@@ -136,9 +137,9 @@ describe('executeToolCallInWorker', () => {
await vi.advanceTimersByTimeAsync(1000);
await expect(resultPromise).resolves.toEqual({
- content: '',
- error: 'Isolated tool worker timed out for grepContent after 1000ms',
- success: false,
+ content: 'Isolated tool worker timed out for grepContent after 1000ms',
+ state: { failureType: 'timeout', success: false, timeoutMs: 1000 },
+ success: true,
});
expect(kill).toHaveBeenCalledWith('SIGKILL');
});
diff --git a/apps/cli/src/tools/isolatedWorker.ts b/apps/cli/src/tools/isolatedWorker.ts
index 2feef0fb42b..e3b706035e3 100644
--- a/apps/cli/src/tools/isolatedWorker.ts
+++ b/apps/cli/src/tools/isolatedWorker.ts
@@ -67,9 +67,9 @@ export async function executeToolCallInWorker(
const timer = setTimeout(() => {
child.kill('SIGKILL');
finish({
- content: '',
- error: `Isolated tool worker timed out for ${apiName} after ${workerTimeout}ms`,
- success: false,
+ content: `Isolated tool worker timed out for ${apiName} after ${workerTimeout}ms`,
+ state: { failureType: 'timeout', success: false, timeoutMs: workerTimeout },
+ success: true,
});
}, workerTimeout);
@@ -93,9 +93,9 @@ export async function executeToolCallInWorker(
const output = stdout.trim();
if (!output) {
finish({
- content: '',
- error: `Isolated tool worker produced no output for ${apiName}`,
- success: false,
+ content: `Isolated tool worker produced no output for ${apiName}`,
+ state: { failureType: 'no_output', success: false },
+ success: true,
});
return;
}
@@ -107,9 +107,9 @@ export async function executeToolCallInWorker(
const errorMsg = error instanceof Error ? error.message : String(error);
const workerOutput = summarizeOutput();
finish({
- content: '',
- error: `Isolated tool worker returned invalid JSON for ${apiName}: ${errorMsg}. Output: ${workerOutput}`,
- success: false,
+ content: `Isolated tool worker returned invalid JSON for ${apiName}: ${errorMsg}. Output: ${workerOutput}`,
+ state: { failureType: 'invalid_json', success: false },
+ success: true,
});
return;
}
@@ -122,9 +122,9 @@ export async function executeToolCallInWorker(
: 'unknown exit';
const workerOutput = summarizeOutput();
finish({
- content: '',
- error: `Isolated tool worker failed for ${apiName} with ${exitReason}: ${workerOutput}`,
- success: false,
+ content: `Isolated tool worker failed for ${apiName} with ${exitReason}: ${workerOutput}`,
+ state: { failureType: 'worker_exit', success: false },
+ success: true,
});
});
});