use crate::function_tool::FunctionCallError; use crate::session::session::Session; use crate::session::turn_context::TurnContext; use akode_protocol::ThreadId; use akode_protocol::error::CodexErrorDetails; use std::sync::Arc; /// Resolves a single tool-facing agent target to a thread id. pub(crate) async fn resolve_agent_target( session: &Arc, turn: &Arc, target: &str, ) -> Result { session .services .agent_control .resolve( session.thread_id, turn.parent_thread_id, &turn.session_source, target, ) .await .map_err(|err| match err.details() { CodexErrorDetails::UnsupportedOperation(message) => { FunctionCallError::RespondToModel(message.clone()) } _ => FunctionCallError::RespondToModel(err.to_string()), }) }