fix(core): handle AbortError when ESC cancels tool execution (#20863)

This commit is contained in:
Prasanna Pal
2026-03-10 22:41:08 +05:30
committed by GitHub
parent a220874281
commit 0b78de9601
3 changed files with 96 additions and 6 deletions
+7 -1
View File
@@ -16,7 +16,7 @@ import {
} from './tools.js';
import { ToolErrorType } from './tool-error.js';
import { getErrorMessage } from '../utils/errors.js';
import { getErrorMessage, isAbortError } from '../utils/errors.js';
import { type Config } from '../config/config.js';
import { getResponseText } from '../utils/partUtils.js';
import { debugLogger } from '../utils/debugLogger.js';
@@ -175,6 +175,12 @@ class WebSearchToolInvocation extends BaseToolInvocation<
sources,
};
} catch (error: unknown) {
if (isAbortError(error)) {
return {
llmContent: 'Web search was cancelled.',
returnDisplay: 'Search cancelled.',
};
}
const errorMessage = `Error during web search for query "${
this.params.query
}": ${getErrorMessage(error)}`;