feat(graph): run map branches as per-item subgraph chains
A map item no longer runs a single branch node; it walks the subgraph reachable from `branch` over `next`/`fallback` edges (branch_subgraph), one chain per item, holding one semaphore permit for the whole chain. Chain steps go through the shared `step()` so llm retries, fallbacks, script `_next` and agent timeouts keep their existing semantics. A node without `next` ends the chain (StepContext.branch_mode), a route outside the subgraph, a fan-out, an end node or a loop past max_loop_iterations fails the item, and every item error carries `map node 'X': sub-branch [i] failed at node 'Y' (step n)`. `output_key` is removed from each item's fork before the chain runs, so the collected value must be written by the chain rather than inherited from the parent. Teammate identities are now per item for the whole chain: provisioned when any flagged agent is in the subgraph, armed only before `teammates: true` agent steps, and retired at chain exit. mark_finished moves out of run_agent_for_graph to the two provisioning sites (frontier task and chain exit), so timed-out and early-failing agents are also marked finished.
This commit is contained in:
5 files changed
+427
-179
No files matched your search
@@ -786,13 +786,7 @@ pub async fn run_agent_for_graph(
|
||||
|
||||
debug!("Spawning agent '{agent_name}' for graph node as '{agent_id}'");
|
||||
|
||||
let result = run_child_agent(child_ctx, input, child_abort).await;
|
||||
|
||||
if let Some(registry) = &peer_registry {
|
||||
registry.mark_finished(&agent_id);
|
||||
}
|
||||
|
||||
result
|
||||
run_child_agent(child_ctx, input, child_abort).await
|
||||
}
|
||||
|
||||
async fn populate_agent_mcp_runtime(ctx: &mut RequestContext, server_ids: &[String]) -> Result<()> {
|
||||
|
||||
Reference in new issue
Block a user