onFailure
infix inline fun <IncomingOutput, OutgoingInput, TResult : ToolResult> AIAgentEdgeBuilderIntermediate<IncomingOutput, SafeTool.Result<TResult>, OutgoingInput>.onFailure(crossinline condition: suspend (error: String) -> Boolean): AIAgentEdgeBuilderIntermediate<IncomingOutput, SafeTool.Result.Failure<TResult>, OutgoingInput>(source)
Defines a handler to process failure cases in a directed edge strategy by applying a condition to filter intermediate results of type SafeTool.Result.Failure
. This method is used to specialize processing for failure results and to propagate or transform them based on the provided condition.
Return
A new instance of AIAgentEdgeBuilderIntermediate
, where the intermediate output type is restricted to SafeTool.Result.Failure
containing the specified TResult
for failure results that match the condition.
Parameters
condition
A suspending lambda function that takes an error message string as input and returns a boolean. It specifies whether the error should be further processed based on the condition provided.