(response: &str)
| 2221 | } |
| 2222 | |
| 2223 | fn parse_subagent_tasks(response: &str) -> Vec<SubagentTask> { |
| 2224 | let mut out = Vec::new(); |
| 2225 | |
| 2226 | if let Ok(value) = serde_json::from_str::<Value>(response) { |
| 2227 | extract_subagent_tasks_from_value(&value, &mut out); |
| 2228 | } |
| 2229 | |
| 2230 | for block in extract_fenced_json_blocks(response) { |
| 2231 | if let Ok(value) = serde_json::from_str::<Value>(&block) { |
| 2232 | extract_subagent_tasks_from_value(&value, &mut out); |
| 2233 | } |
| 2234 | } |
| 2235 | |
| 2236 | for candidate in extract_braced_json_candidates(response) { |
| 2237 | if let Ok(value) = serde_json::from_str::<Value>(&candidate) { |
| 2238 | extract_subagent_tasks_from_value(&value, &mut out); |
| 2239 | } |
| 2240 | } |
| 2241 | |
| 2242 | let mut seen = HashSet::new(); |
| 2243 | out.into_iter() |
| 2244 | .filter(|task| { |
| 2245 | let key = format!("{}::{}", task.agent_type, task.task); |
| 2246 | seen.insert(key) |
| 2247 | }) |
| 2248 | .collect() |
| 2249 | } |
| 2250 | |
| 2251 | fn extract_subagent_tasks_from_value(value: &Value, out: &mut Vec<SubagentTask>) { |
| 2252 | let Some(subagents) = value.get("subagents").and_then(Value::as_array) else { |
no test coverage detected