feat: 添加技能索引支持到子代理系统提示词构建,优化提示词组合逻辑
This commit is contained in:
parent
b364496601
commit
fc628239a4
@ -106,6 +106,7 @@ pub(crate) fn build_session_manager_with_sender(
|
|||||||
explore_max_execution_secs: task_config.explore_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,
|
||||||
|
skills_index: skills.system_index_prompt(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let subagent_runtime = Arc::new(DefaultSubAgentRuntime::new(
|
let subagent_runtime = Arc::new(DefaultSubAgentRuntime::new(
|
||||||
|
|||||||
@ -5,19 +5,27 @@ use crate::config::LLMProviderConfig;
|
|||||||
pub struct SubagentPromptBuilder;
|
pub struct SubagentPromptBuilder;
|
||||||
|
|
||||||
impl SubagentPromptBuilder {
|
impl SubagentPromptBuilder {
|
||||||
/// 构建子代理系统提示词(包含系统环境信息)
|
/// 构建子代理系统提示词(包含系统环境信息和技能索引)
|
||||||
pub fn build(
|
pub fn build(
|
||||||
subagent_type: SubagentType,
|
subagent_type: SubagentType,
|
||||||
description: &str,
|
description: &str,
|
||||||
_prompt: &str,
|
_prompt: &str,
|
||||||
config: &LLMProviderConfig,
|
config: &LLMProviderConfig,
|
||||||
|
skills_index: Option<&str>,
|
||||||
) -> String {
|
) -> String {
|
||||||
let base_prompt = match subagent_type {
|
let base_prompt = match subagent_type {
|
||||||
SubagentType::General => Self::build_general_prompt(description),
|
SubagentType::General => Self::build_general_prompt(description),
|
||||||
SubagentType::Explore => Self::build_explore_prompt(description),
|
SubagentType::Explore => Self::build_explore_prompt(description),
|
||||||
};
|
};
|
||||||
let env_info = crate::agent::generate_system_env_prompt(config);
|
let env_info = crate::agent::generate_system_env_prompt(config);
|
||||||
format!("{}\n\n{}", base_prompt, env_info)
|
|
||||||
|
// 组合提示词:基础 + 环境 + 技能索引(可选)
|
||||||
|
match skills_index {
|
||||||
|
Some(index) if !index.is_empty() => {
|
||||||
|
format!("{}\n\n{}\n\n{}", base_prompt, env_info, index)
|
||||||
|
}
|
||||||
|
_ => format!("{}\n\n{}", base_prompt, env_info),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 构建恢复任务的提示词
|
/// 构建恢复任务的提示词
|
||||||
|
|||||||
@ -28,6 +28,8 @@ pub struct SubAgentRuntimeConfig {
|
|||||||
pub explore_max_tool_calls: usize,
|
pub explore_max_tool_calls: usize,
|
||||||
/// 任务 TTL(小时)
|
/// 任务 TTL(小时)
|
||||||
pub ttl_hours: u64,
|
pub ttl_hours: u64,
|
||||||
|
/// 技能索引(可选,预生成的技能列表字符串)
|
||||||
|
pub skills_index: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for SubAgentRuntimeConfig {
|
impl Default for SubAgentRuntimeConfig {
|
||||||
@ -51,6 +53,7 @@ impl Default for SubAgentRuntimeConfig {
|
|||||||
explore_max_execution_secs: 600, // 10分钟
|
explore_max_execution_secs: 600, // 10分钟
|
||||||
explore_max_tool_calls: 20,
|
explore_max_tool_calls: 20,
|
||||||
ttl_hours: 24,
|
ttl_hours: 24,
|
||||||
|
skills_index: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -282,6 +285,7 @@ impl SubAgentRuntime for DefaultSubAgentRuntime {
|
|||||||
&task.description,
|
&task.description,
|
||||||
&task.prompt,
|
&task.prompt,
|
||||||
&self.provider_config,
|
&self.provider_config,
|
||||||
|
self.config.skills_index.as_deref(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// 5. 创建子代理
|
// 5. 创建子代理
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user