diff --git a/src/gateway/runtime.rs b/src/gateway/runtime.rs index b43a5f8..110319e 100644 --- a/src/gateway/runtime.rs +++ b/src/gateway/runtime.rs @@ -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( diff --git a/src/tools/task/prompt.rs b/src/tools/task/prompt.rs index 8547218..3608e76 100644 --- a/src/tools/task/prompt.rs +++ b/src/tools/task/prompt.rs @@ -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), + } } /// 构建恢复任务的提示词 diff --git a/src/tools/task/runtime.rs b/src/tools/task/runtime.rs index 530efe1..7fd60a8 100644 --- a/src/tools/task/runtime.rs +++ b/src/tools/task/runtime.rs @@ -28,6 +28,8 @@ pub struct SubAgentRuntimeConfig { pub explore_max_tool_calls: usize, /// 任务 TTL(小时) pub ttl_hours: u64, + /// 技能索引(可选,预生成的技能列表字符串) + pub skills_index: Option, } 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. 创建子代理