feat(TASK-009): add fallback routing to agent nodes
Agent nodes gain an optional fallback target with llm-node parity: on any failure (retries exhausted, hard error, or structured-extraction failure) the failure chain is written into state as 'Agent node failed: <chain>' and the chain routes to the fallback node. Without a fallback the error propagates unchanged. Validator collects agent fallback edges for missing-target checks, reachability, and map-branch locality.
This commit is contained in:
5 files changed
+416
-57
No files matched your search
+10
-3
@@ -1,4 +1,4 @@
|
||||
use super::agent::AgentNodeExecutor;
|
||||
use super::agent::{AgentExecutionOutcome, AgentNodeExecutor};
|
||||
use super::llm::{LlmExecutionOutcome, LlmNodeExecutor};
|
||||
use super::logging::{GraphLogger, narrate_node_complete, narrate_node_failed};
|
||||
use super::map::MapNodeExecutor;
|
||||
@@ -574,8 +574,14 @@ pub(super) async fn step(
|
||||
) -> Result<StepResult> {
|
||||
match &node.node_type {
|
||||
NodeType::Agent(agent_node) => {
|
||||
AgentNodeExecutor::execute(agent_node, state, ctx, !step_ctx.branch_mode).await?;
|
||||
let targets = static_next_targets(node, current, "agent", step_ctx.branch_mode)?;
|
||||
let outcome =
|
||||
AgentNodeExecutor::execute(agent_node, state, ctx, !step_ctx.branch_mode).await?;
|
||||
let targets = match outcome {
|
||||
AgentExecutionOutcome::Continue(_) => {
|
||||
static_next_targets(node, current, "agent", step_ctx.branch_mode)?
|
||||
}
|
||||
AgentExecutionOutcome::FellBack(target) => vec![target],
|
||||
};
|
||||
Ok(StepResult::Continue(targets))
|
||||
}
|
||||
NodeType::Script(script_node) => {
|
||||
@@ -828,6 +834,7 @@ mod tests {
|
||||
output_schema: None,
|
||||
timeout: None,
|
||||
max_attempts: 1,
|
||||
fallback: None,
|
||||
inputs: None,
|
||||
teammates,
|
||||
}),
|
||||
|
||||
Reference in new issue
Block a user