feat: 添加探索类型最大执行时间配置,优化子代理任务执行逻辑
This commit is contained in:
parent
bee1a39a06
commit
6b5d45e3a5
@ -1004,6 +1004,18 @@ impl AgentLoop {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Multiple Task tools can run in parallel
|
||||||
|
// Task tools create independent subagents with isolated contexts, no shared state
|
||||||
|
let task_count = tool_calls.iter().filter(|tc| tc.name == "task").count();
|
||||||
|
if task_count > 1 && task_count == tool_calls.len() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// When Task is mixed with other tools, keep sequential to avoid complexity
|
||||||
|
if task_count > 0 {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// All tools must be concurrency-safe to run in parallel
|
// All tools must be concurrency-safe to run in parallel
|
||||||
tool_calls.iter().all(|tc| {
|
tool_calls.iter().all(|tc| {
|
||||||
self.tools
|
self.tools
|
||||||
|
|||||||
@ -114,6 +114,8 @@ pub struct TaskConfig {
|
|||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
#[serde(default = "default_task_max_execution_secs")]
|
#[serde(default = "default_task_max_execution_secs")]
|
||||||
pub max_execution_secs: u64,
|
pub max_execution_secs: u64,
|
||||||
|
#[serde(default = "default_task_explore_max_execution_secs")]
|
||||||
|
pub explore_max_execution_secs: u64,
|
||||||
#[serde(default = "default_task_ttl_hours")]
|
#[serde(default = "default_task_ttl_hours")]
|
||||||
pub ttl_hours: u64,
|
pub ttl_hours: u64,
|
||||||
#[serde(default = "default_task_allowed_tools")]
|
#[serde(default = "default_task_allowed_tools")]
|
||||||
@ -125,7 +127,11 @@ fn default_task_enabled() -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn default_task_max_execution_secs() -> u64 {
|
fn default_task_max_execution_secs() -> u64 {
|
||||||
300
|
1200 // 20分钟
|
||||||
|
}
|
||||||
|
|
||||||
|
fn default_task_explore_max_execution_secs() -> u64 {
|
||||||
|
600 // 10分钟
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_task_ttl_hours() -> u64 {
|
fn default_task_ttl_hours() -> u64 {
|
||||||
@ -154,6 +160,7 @@ impl Default for TaskConfig {
|
|||||||
Self {
|
Self {
|
||||||
enabled: default_task_enabled(),
|
enabled: default_task_enabled(),
|
||||||
max_execution_secs: default_task_max_execution_secs(),
|
max_execution_secs: default_task_max_execution_secs(),
|
||||||
|
explore_max_execution_secs: default_task_explore_max_execution_secs(),
|
||||||
ttl_hours: default_task_ttl_hours(),
|
ttl_hours: default_task_ttl_hours(),
|
||||||
allowed_tools: default_task_allowed_tools(),
|
allowed_tools: default_task_allowed_tools(),
|
||||||
}
|
}
|
||||||
|
|||||||
@ -104,6 +104,7 @@ pub(crate) fn build_session_manager_with_sender(
|
|||||||
let runtime_config = SubAgentRuntimeConfig {
|
let runtime_config = SubAgentRuntimeConfig {
|
||||||
allowed_tools: task_config.allowed_tools.iter().cloned().collect(),
|
allowed_tools: task_config.allowed_tools.iter().cloned().collect(),
|
||||||
max_execution_secs: task_config.max_execution_secs,
|
max_execution_secs: task_config.max_execution_secs,
|
||||||
|
explore_max_execution_secs: task_config.explore_max_execution_secs,
|
||||||
explore_max_tool_calls: 20,
|
explore_max_tool_calls: 20,
|
||||||
ttl_hours: task_config.ttl_hours,
|
ttl_hours: task_config.ttl_hours,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -20,8 +20,10 @@ use super::types::{SubagentType, TaskDefinition, TaskHandle, TaskSession, TaskSe
|
|||||||
pub struct SubAgentRuntimeConfig {
|
pub struct SubAgentRuntimeConfig {
|
||||||
/// 子代理可用的工具列表(白名单)
|
/// 子代理可用的工具列表(白名单)
|
||||||
pub allowed_tools: HashSet<String>,
|
pub allowed_tools: HashSet<String>,
|
||||||
/// 最大执行时间(秒)
|
/// 最大执行时间(秒) - General 类型
|
||||||
pub max_execution_secs: u64,
|
pub max_execution_secs: u64,
|
||||||
|
/// Explore 类型的最大执行时间(秒)
|
||||||
|
pub explore_max_execution_secs: u64,
|
||||||
/// 探索类型的最大工具调用次数
|
/// 探索类型的最大工具调用次数
|
||||||
pub explore_max_tool_calls: usize,
|
pub explore_max_tool_calls: usize,
|
||||||
/// 任务 TTL(小时)
|
/// 任务 TTL(小时)
|
||||||
@ -45,7 +47,8 @@ impl Default for SubAgentRuntimeConfig {
|
|||||||
"skill_list".to_string(),
|
"skill_list".to_string(),
|
||||||
"send_session_message".to_string(), // 用于进度通知
|
"send_session_message".to_string(), // 用于进度通知
|
||||||
]),
|
]),
|
||||||
max_execution_secs: 300, // 5分钟
|
max_execution_secs: 1200, // 20分钟
|
||||||
|
explore_max_execution_secs: 600, // 10分钟
|
||||||
explore_max_tool_calls: 20,
|
explore_max_tool_calls: 20,
|
||||||
ttl_hours: 24,
|
ttl_hours: 24,
|
||||||
}
|
}
|
||||||
@ -168,7 +171,7 @@ impl DefaultSubAgentRuntime {
|
|||||||
|
|
||||||
// 设置超时
|
// 设置超时
|
||||||
let max_secs = if session.subagent_type == SubagentType::Explore {
|
let max_secs = if session.subagent_type == SubagentType::Explore {
|
||||||
self.config.max_execution_secs / 2 // Explore 类型时间更短
|
self.config.explore_max_execution_secs
|
||||||
} else {
|
} else {
|
||||||
self.config.max_execution_secs
|
self.config.max_execution_secs
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user