From fc628239a4866a4e1fc9c751dd34bc84f1f8770a Mon Sep 17 00:00:00 2001 From: oudecheng <13802883547@139.com> Date: Wed, 20 May 2026 15:34:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=8A=80=E8=83=BD?= =?UTF-8?q?=E7=B4=A2=E5=BC=95=E6=94=AF=E6=8C=81=E5=88=B0=E5=AD=90=E4=BB=A3?= =?UTF-8?q?=E7=90=86=E7=B3=BB=E7=BB=9F=E6=8F=90=E7=A4=BA=E8=AF=8D=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=EF=BC=8C=E4=BC=98=E5=8C=96=E6=8F=90=E7=A4=BA=E8=AF=8D?= =?UTF-8?q?=E7=BB=84=E5=90=88=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gateway/runtime.rs | 1 + src/tools/task/prompt.rs | 12 ++++++++++-- src/tools/task/runtime.rs | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) 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. 创建子代理