Skip to content

ToolError

An intentional, model-visible tool error.

Never include secret values or internal stack traces in the message — it is visible to the model and potentially the user. Describe the problem at the level of the tool’s semantics, not the implementation.

throw new ToolError(`Order ${orderId} not found`, { retryable: false });
  • Error
new ToolError(message: string, options?: ToolErrorOptions): ToolError;
ParameterTypeDescription
messagestringHuman-readable, model-safe error message.
options?ToolErrorOptionsOptional retryable hint and structured data.

ToolError

Error.constructor
PropertyModifierTypeDescriptionInherited from
cause?publicunknown-Error.cause
datareadonlyunknownOptional structured data attached to the error.-
messagepublicstring-Error.message
namepublicstring-Error.name
retryablereadonlybooleanWhether the model should consider retrying the call.-
stack?publicstring-Error.stack