Skip to main content

run_graph

Function run_graph 

Source
pub async fn run_graph(
    ctx: &mut RunCtx,
    graph: &Graph,
    input: &Value,
    agents: &impl AgentResolver,
    tools: &impl ToolResolver,
) -> Result<GraphOutcome, EngineError>
Expand description

Drives graph to completion (or a park) over ctx, recording the walk into the run’s log.

The log opens with GraphRunStarted { graph_hash }, each node contributes NodeEntered … its own events … NodeExited, and the run closes with one RunCompleted. See the crate docs for the node handling and determinism guarantees. Fresh, recovering, or replaying is entirely the ctx’s business: the engine issues the same sequence of RunCtx calls either way, which is what makes a second drive over the recorded log a byte-identical, zero-live-call replay.

§Errors

EngineError::MapOverNotAList when a map node’s over reference does not resolve to a list, and EngineError::UnsupportedMapBody for a subgraph or non-agent/tool body (both before the map’s NodeEntered is recorded); EngineError::NoBranchCaseMatched when an expression branch matches no case (also before its NodeEntered); EngineError::BranchDecisionUnmatched when a model-decision branch’s agent names no case (after its NodeEntered, since the model had to run); EngineError::UnknownAgent / EngineError::UnknownTool when a resolver cannot supply a node’s executable; EngineError::MalformedGraph when the topology is not a DAG (or, unreachable in practice, a branch condition the validator accepted fails to parse here); EngineError::ToolFailed when a tool call fails; EngineError::Runtime for any replay divergence, reconciliation refusal, provider, or store error.