diff --git a/src/tools/task/runtime.rs b/src/tools/task/runtime.rs index 7fd60a8..505f2e0 100644 --- a/src/tools/task/runtime.rs +++ b/src/tools/task/runtime.rs @@ -188,6 +188,13 @@ impl DefaultSubAgentRuntime { match result { Ok(Ok(process_result)) => { + // 保存子智能体产生的所有消息到数据库 + for message in &process_result.emitted_messages { + if let Err(e) = self.conversation_repository.append_message(&session.session_id, message) { + tracing::warn!(error = %e, session_id = %session.session_id, "Failed to append subagent message"); + } + } + let final_message = process_result.final_response; Ok(TaskToolResult { status: "success".to_string(), @@ -232,6 +239,13 @@ impl DefaultSubAgentRuntime { match result { Ok(Ok(process_result)) => { + // 保存子智能体产生的所有消息到数据库 + for message in &process_result.emitted_messages { + if let Err(e) = self.conversation_repository.append_message(&session.session_id, message) { + tracing::warn!(error = %e, session_id = %session.session_id, "Failed to append subagent message"); + } + } + let final_message = process_result.final_response; Ok(TaskToolResult { status: "success".to_string(),