mirror of
https://github.com/aljazceru/goose.git
synced 2026-01-31 12:14:32 +01:00
fix: use sequential when sub recipe task is 1. (#3573)
This commit is contained in:
@@ -73,10 +73,15 @@ fn create_tasks_from_params(
|
||||
}
|
||||
|
||||
fn create_task_execution_payload(tasks: &[Task], sub_recipe: &SubRecipe) -> Value {
|
||||
let execution_mode = if tasks.len() == 1 || sub_recipe.sequential_when_repeated {
|
||||
ExecutionMode::Sequential
|
||||
} else {
|
||||
ExecutionMode::Parallel
|
||||
};
|
||||
let task_ids: Vec<String> = tasks.iter().map(|task| task.id.clone()).collect();
|
||||
json!({
|
||||
"task_ids": task_ids,
|
||||
"execution_mode": if sub_recipe.sequential_when_repeated { ExecutionMode::Sequential } else { ExecutionMode::Parallel },
|
||||
"execution_mode": execution_mode,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -25,18 +25,7 @@ pub async fn execute_tasks(
|
||||
)
|
||||
.map_err(|e| format!("Failed to parse task_ids: {}", e))?;
|
||||
|
||||
let mut tasks = Vec::new();
|
||||
for task_id in &task_ids {
|
||||
match tasks_manager.get_task(task_id).await {
|
||||
Some(task) => tasks.push(task),
|
||||
None => {
|
||||
return Err(format!(
|
||||
"Task with ID '{}' not found in TasksManager",
|
||||
task_id
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
let tasks = tasks_manager.get_tasks(&task_ids).await?;
|
||||
|
||||
let task_count = tasks.len();
|
||||
match execution_mode {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use anyhow::Result;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
@@ -33,6 +34,22 @@ impl TasksManager {
|
||||
let tasks = self.tasks.read().await;
|
||||
tasks.get(task_id).cloned()
|
||||
}
|
||||
|
||||
pub async fn get_tasks(&self, task_ids: &[String]) -> Result<Vec<Task>, String> {
|
||||
let mut tasks = Vec::new();
|
||||
for task_id in task_ids {
|
||||
match self.get_task(task_id).await {
|
||||
Some(task) => tasks.push(task),
|
||||
None => {
|
||||
return Err(format!(
|
||||
"Task with ID '{}' not found in TasksManager",
|
||||
task_id
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(tasks)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user