Fix coding agent tools to return error content instead of throwing
Tools now resolve with error messages in content blocks rather than rejecting the promise. This matches the expected behavior where tools always return a result, with errors indicated in the text content. - read: Return error content for missing files - edit: Return error content for missing files, text not found, multiple matches - bash: Return error content for command failures, timeouts, and aborts - All tools now include required details field in error results
This commit is contained in:
@@ -82,7 +82,10 @@ export const readTool: AgentTool<typeof readSchema> = {
|
||||
if (signal) {
|
||||
signal.removeEventListener("abort", onAbort);
|
||||
}
|
||||
reject(new Error(`File not found: ${path}`));
|
||||
resolve({
|
||||
content: [{ type: "text", text: `Error: File not found: ${path}` }],
|
||||
details: undefined,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user