#[non_exhaustive]pub enum EdgeCondition {
HasToolCalls,
IsFinalAnswer,
RequestsDelegation,
ErrorOccurred,
StateEquals {
variable: String,
value: String,
},
Always,
Custom {
name: String,
description: String,
},
ParadigmEquals {
paradigm: String,
},
IterationExceeds {
count: usize,
},
}Expand description
A condition that determines whether an edge is followed.
Edges with conditions enable dynamic routing in the graph:
- After an LLM inference node, route to tool execution if tool calls present
- After a tool execution node, route back to LLM inference (ReAct loop)
- After an LLM inference node, route to end if no tool calls (final answer)
P2-2 improvement: HasToolCalls, IsFinalAnswer, and RequestsDelegation
now evaluate against GraphState.parsed_decision (a structured GraphDecision)
rather than unreliable string pattern matching. This makes edge routing
consistent with the AgentLoop’s decision parsing.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
HasToolCalls
Route if the model output contains tool calls.
Now evaluates state.parsed_decision == GraphDecision::ToolCalls.
IsFinalAnswer
Route if the model output is a final answer (no tool calls).
Now evaluates state.parsed_decision == GraphDecision::DirectAnswer.
RequestsDelegation
Route if the model output requests delegation.
Now evaluates state.parsed_decision == GraphDecision::Delegate.
ErrorOccurred
Route if an error occurred in the previous node.
StateEquals
Route if a specific state variable has a certain value.
Always
Always route (no condition — unconditional edge).
Custom
Custom condition — evaluated by a user-provided function.
ParadigmEquals
Route if the active paradigm matches the specified paradigm.
Evaluates state.active_paradigm == paradigm.
IterationExceeds
Route if the iteration count exceeds the specified threshold. Useful for adding safety caps to iterative loops.
Implementations§
Source§impl EdgeCondition
impl EdgeCondition
Sourcepub fn is_unconditional(&self) -> bool
pub fn is_unconditional(&self) -> bool
Check if this condition is unconditional (always routes).