ai icon indicating copy to clipboard operation
ai copied to clipboard

Support continue generation when tool calling fails

Open wong2 opened this issue 9 months ago • 0 comments

Description

Currently, when errors happen in tool execution, an exception is thrown and the generation stops. However, error is actually a valid result for function calling in OpenAI/Anthropic. So it would be great if the user can decide if they want to use the error as tool result.

Right now, I've got a hacky way to do it: I catch the error in the tool's execute function and return it instead of throwing it. Then, when streaming, I check if the tool result is an instance of an error. While this works, I'm hoping for a more standard way to achieve this.

wong2 avatar Apr 14 '25 09:04 wong2