Responses: Hallucinated tool call

Question how to best handle this: I get a useful final response AND tool calls. On top of that the tool “search” doesn’t exist.


Generally speaking: should I submit an error response for tool calls to tools that don’t exist?

Should I ignore the tool calls if the structured output already fits my schema?

1 Like

First, no reason to add a tool for time and date. Inject that into the system message - it is less tokens than the specifications for a tool, and certainly less than a repeat API call. Or if trying to preserve cache, right before the latest user input.

I would set “parallel_tool_calls” API parameter to false.

Something about that additional function-wrapper tool is likely inspiring the AI to emit to it, and then once within, the AI has to come up with something to produce.

## multi_tool_use

// This tool serves as a wrapper for utilizing multiple tools. Each tool that can be used must be specified in the tool sections. Only tools in the functions namespace are permitted.
// Ensure that the parameters provided to each tool are valid according to that tool's specification.
namespace multi_tool_use {

// Use this function to run multiple tools simultaneously, but only if they can operate in parallel. Do this even if the prompt suggests using the tools sequentially.
type parallel = (_: {
// The tools to be executed in parallel. NOTE: only functions tools are permitted
tool_uses: {
// The name of the tool to use. The format should either be just the name of the tool, or in the format namespace.function_name for plugin and function tools.
recipient_name: string,
// The parameters to pass to the tool. Ensure these are valid according to the tool's own specifications.
parameters: object,
}[],
}) => any;

} // namespace multi_tool_use

If you get a tool call and no user content, you pretty much have to answer it with a response, especially if using previous ID of Responses. “invalid function name; multi_tool_use cannot be used for this response again, bad bot”.

An alternate would be to place an additional message that would counter a bad tool use and run the input again, but that would have to be pretty clever to anticipate and “disable” any junk that the AI may be predisposed to make from an input context. A message “respond to user, no functions, no tools” would counter the perceived need to use a tool and the chance for the AI to correct itself.

1 Like