ToolRefusal
Raise ToolRefusal from a tool handler, or from tool
middleware, to decline the call with an outcome you know, such
as an item out of stock or an account that isn’t found. The model gets tool_result,
which says what is true now, and tool_prompt, which says what to do next.
Any other exception a handler raises is logged, not sent: the model is told the
function failed before it finished, so whether it took effect is unknown. See the
handler parameter of define_tool().
Parameters
tool_result
What is true now: that nothing was done, and why. It’s also the exception’s message.
tool_prompt
What the model should do next.
Methods
Example
The model gets: