feat: ToolError migration to ErrorData (#4051)

This commit is contained in:
Alex Hancock
2025-08-12 16:18:41 -04:00
committed by GitHub
parent 88b013194c
commit bd1eff52a4
35 changed files with 2459 additions and 1336 deletions
+8 -4
View File
@@ -1,7 +1,7 @@
use crate::agents::subagent::SubAgent;
use crate::agents::subagent_task_config::TaskConfig;
use anyhow::Result;
use mcp_core::ToolError;
use rmcp::model::{ErrorCode, ErrorData};
/// Standalone function to run a complete subagent task
pub async fn run_complete_subagent_task(
@@ -9,9 +9,13 @@ pub async fn run_complete_subagent_task(
task_config: TaskConfig,
) -> Result<String, anyhow::Error> {
// Create the subagent with the parent agent's provider
let subagent = SubAgent::new(task_config.clone())
.await
.map_err(|e| ToolError::ExecutionError(format!("Failed to create subagent: {}", e)))?;
let subagent = SubAgent::new(task_config.clone()).await.map_err(|e| {
ErrorData::new(
ErrorCode::INTERNAL_ERROR,
format!("Failed to create subagent: {}", e),
None,
)
})?;
// Execute the subagent task
let messages = subagent