toSafeResult
fun <TResult> ReceivedToolResult.toSafeResult(tool: Tool<*, TResult>): SafeTool.Result<TResult>(source)
Converts a ReceivedToolResult instance into a SafeTool.Result for safer result handling.
If the result in the ReceivedToolResult is null, it returns a SafeTool.Result.Failure containing the content as a failure message. Otherwise, it casts the result to the given type parameter TResult and returns a SafeTool.Result.Success containing the result and content.
Return
A SafeTool.Result which will either be a SafeTool.Result.Failure or SafeTool.Result.Success based on the presence and validity of the result in the ReceivedToolResult.