Make async (#5126)

Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
Douwe Osinga
2025-10-10 19:31:50 -04:00
committed by GitHub
parent 69a7b7fe5a
commit 1015064367
43 changed files with 343 additions and 480 deletions
@@ -755,7 +755,7 @@ impl AutoPilot {
self.current_role = Some(best_model.role.clone());
let model = crate::model::ModelConfig::new_or_fail(&best_model.model);
let new_provider = providers::create(&best_model.provider, model)?;
let new_provider = providers::create(&best_model.provider, model).await?;
return Ok(Some((
new_provider,
+4 -3
View File
@@ -5,9 +5,10 @@ use crate::{
session::SessionManager,
};
use anyhow::{anyhow, Result};
use futures::future::BoxFuture;
use futures::StreamExt;
use rmcp::model::{ErrorCode, ErrorData};
use std::future::Future;
use std::pin::Pin;
use tracing::debug;
/// Standalone function to run a complete subagent task with output options
@@ -93,7 +94,7 @@ pub async fn run_complete_subagent_task(
fn get_agent_messages(
text_instruction: String,
task_config: TaskConfig,
) -> BoxFuture<'static, Result<Conversation>> {
) -> Pin<Box<dyn Future<Output = Result<Conversation>> + Send>> {
Box::pin(async move {
let agent_manager = AgentManager::instance()
.await
@@ -148,7 +149,7 @@ fn get_agent_messages(
Ok(AgentEvent::Message(msg)) => session_messages.push(msg),
Ok(AgentEvent::McpNotification(_))
| Ok(AgentEvent::ModelChange { .. })
| Ok(AgentEvent::HistoryReplaced(_)) => {} // Handle informational events
| Ok(AgentEvent::HistoryReplaced(_)) => {}
Err(e) => {
tracing::error!("Error receiving message from subagent: {}", e);
break;