feat: 添加技能索引支持到子代理系统提示词构建,优化提示词组合逻辑

This commit is contained in:
oudecheng 2026-05-20 15:34:34 +08:00
parent b364496601
commit fc628239a4
3 changed files with 15 additions and 2 deletions

View File

@ -106,6 +106,7 @@ pub(crate) fn build_session_manager_with_sender(
explore_max_execution_secs: task_config.explore_max_execution_secs,
explore_max_tool_calls: 20,
ttl_hours: task_config.ttl_hours,
skills_index: skills.system_index_prompt(),
};
let subagent_runtime = Arc::new(DefaultSubAgentRuntime::new(

View File

@ -5,19 +5,27 @@ use crate::config::LLMProviderConfig;
pub struct SubagentPromptBuilder;
impl SubagentPromptBuilder {
/// 构建子代理系统提示词(包含系统环境信息
/// 构建子代理系统提示词(包含系统环境信息和技能索引
pub fn build(
subagent_type: SubagentType,
description: &str,
_prompt: &str,
config: &LLMProviderConfig,
skills_index: Option<&str>,
) -> String {
let base_prompt = match subagent_type {
SubagentType::General => Self::build_general_prompt(description),
SubagentType::Explore => Self::build_explore_prompt(description),
};
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),
}
}
/// 构建恢复任务的提示词

View File

@ -28,6 +28,8 @@ pub struct SubAgentRuntimeConfig {
pub explore_max_tool_calls: usize,
/// 任务 TTL小时
pub ttl_hours: u64,
/// 技能索引(可选,预生成的技能列表字符串)
pub skills_index: Option<String>,
}
impl Default for SubAgentRuntimeConfig {
@ -51,6 +53,7 @@ impl Default for SubAgentRuntimeConfig {
explore_max_execution_secs: 600, // 10分钟
explore_max_tool_calls: 20,
ttl_hours: 24,
skills_index: None,
}
}
}
@ -282,6 +285,7 @@ impl SubAgentRuntime for DefaultSubAgentRuntime {
&task.description,
&task.prompt,
&self.provider_config,
self.config.skills_index.as_deref(),
);
// 5. 创建子代理