subgraphWithRetrySimple
Creates a subgraph that includes retry functionality based on a given condition and a maximum number of retries. If the condition is not met after the specified retries and strict mode is enabled, an exception is thrown. Unlike subgraphWithRetry, this function directly returns the output value instead of a RetrySubgraphResult.
Parameters
A suspendable function that determines whether the condition is met, based on the output.
The maximum number of retries allowed if the condition is not met.
A message which explains the condition constraints to the model
The strategy used to select tools for this subgraph.
If true, an exception is thrown if the condition is not met after the maximum retries.
An optional name for the subgraph.
A lambda defining the actions within the subgraph.
Example usage:
val subgraphRetryCallLLM by subgraphWithRetrySimple(
condition = { (it is Message.Tool.Call).asConditionResult },
maxRetries = 2,
) {
val nodeCallLLM by nodeLLMRequest("sendInput")
nodeStart then nodeCallLLM then nodeFinish
}
val nodeExecuteTool by nodeExecuteTool("nodeExecuteTool")
edge(subgraphRetryCallLLM forwardTo nodeExecuteTool onToolCall { true })