fix(core): use returnDisplay for error result display (#14994)

Co-authored-by: Sehoon Shon <sshon@google.com>
This commit is contained in:
Mark Cockram
2026-01-29 04:02:39 +01:00
committed by GitHub
parent 7c2cdb225a
commit ba3e1ed1c7
+16 -3
View File
@@ -123,10 +123,15 @@ export class ToolExecutor {
} else if (toolResult.error === undefined) { } else if (toolResult.error === undefined) {
return await this.createSuccessResult(call, toolResult); return await this.createSuccessResult(call, toolResult);
} else { } else {
const displayText =
typeof toolResult.returnDisplay === 'string'
? toolResult.returnDisplay
: undefined;
return this.createErrorResult( return this.createErrorResult(
call, call,
new Error(toolResult.error.message), new Error(toolResult.error.message),
toolResult.error.type, toolResult.error.type,
displayText,
); );
} }
} catch (executionError: unknown) { } catch (executionError: unknown) {
@@ -271,8 +276,14 @@ export class ToolExecutor {
call: ToolCall, call: ToolCall,
error: Error, error: Error,
errorType?: ToolErrorType, errorType?: ToolErrorType,
returnDisplay?: string,
): ErroredToolCall { ): ErroredToolCall {
const response = this.createErrorResponse(call.request, error, errorType); const response = this.createErrorResponse(
call.request,
error,
errorType,
returnDisplay,
);
const startTime = 'startTime' in call ? call.startTime : undefined; const startTime = 'startTime' in call ? call.startTime : undefined;
return { return {
@@ -289,7 +300,9 @@ export class ToolExecutor {
request: ToolCallRequestInfo, request: ToolCallRequestInfo,
error: Error, error: Error,
errorType: ToolErrorType | undefined, errorType: ToolErrorType | undefined,
returnDisplay?: string,
): ToolCallResponseInfo { ): ToolCallResponseInfo {
const displayText = returnDisplay ?? error.message;
return { return {
callId: request.callId, callId: request.callId,
error, error,
@@ -302,9 +315,9 @@ export class ToolExecutor {
}, },
}, },
], ],
resultDisplay: error.message, resultDisplay: displayText,
errorType, errorType,
contentLength: error.message.length, contentLength: displayText.length,
}; };
} }
} }