feat: support explicit can_spawn_agents, max_concurrent_agents, and max_agent_depth keys in graph.yaml
Graph agents previously derived can_spawn_agents from the presence of an agent node, so a pure-LLM-node graph could never spawn dynamic sub-agents. The three optional graph-level keys now override the derivation/defaults in AgentConfig::from_graph, enabling orchestrator graphs (can_spawn_agents: true with only llm nodes). Explicit false on a graph with agent nodes still runs those nodes; only dynamic spawning from llm nodes is disabled.
This commit is contained in:
3 files changed
+115
-5
No files matched your search
@@ -31,6 +31,15 @@ pub struct Graph {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub max_concurrent_jobs: Option<usize>,
|
||||
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub can_spawn_agents: Option<bool>,
|
||||
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub max_concurrent_agents: Option<usize>,
|
||||
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub max_agent_depth: Option<usize>,
|
||||
|
||||
#[serde(default)]
|
||||
pub global_tools: Vec<String>,
|
||||
|
||||
@@ -946,11 +955,34 @@ nodes:
|
||||
assert!(graph.temperature.is_none());
|
||||
assert!(graph.top_p.is_none());
|
||||
assert!(graph.max_concurrent_jobs.is_none());
|
||||
assert!(graph.can_spawn_agents.is_none());
|
||||
assert!(graph.max_concurrent_agents.is_none());
|
||||
assert!(graph.max_agent_depth.is_none());
|
||||
assert!(graph.global_tools.is_empty());
|
||||
assert!(graph.mcp_servers.is_empty());
|
||||
assert!(graph.conversation_starters.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn graph_parses_agent_orchestration_keys() {
|
||||
let yaml = r#"
|
||||
name: g
|
||||
can_spawn_agents: true
|
||||
max_concurrent_agents: 6
|
||||
max_agent_depth: 2
|
||||
start: x
|
||||
nodes:
|
||||
x:
|
||||
id: x
|
||||
type: end
|
||||
output: ok
|
||||
"#;
|
||||
let graph: Graph = serde_yaml::from_str(yaml).unwrap();
|
||||
assert_eq!(graph.can_spawn_agents, Some(true));
|
||||
assert_eq!(graph.max_concurrent_agents, Some(6));
|
||||
assert_eq!(graph.max_agent_depth, Some(2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn node_ids_lists_nodes_in_order() {
|
||||
let yaml = r#"
|
||||
|
||||
Reference in new issue
Block a user