Skip to main content

AgentExecutor

Trait AgentExecutor 

Source
pub trait AgentExecutor: Send + Sync {
    // Required methods
    fn executor_type(&self) -> ExecutorType;
    fn spawn<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        working_dir: &'life1 Path,
        prompt: &'life2 str,
        config: &'life3 SpawnConfig,
    ) -> Pin<Box<dyn Future<Output = Result<AgentSession>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn resume<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>(
        &'life0 self,
        working_dir: &'life1 Path,
        prompt: &'life2 str,
        session_id: &'life3 str,
        reset_to: Option<&'life4 str>,
        config: &'life5 SpawnConfig,
    ) -> Pin<Box<dyn Future<Output = Result<AgentSession>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait,
             'life5: 'async_trait;
    fn capabilities(&self) -> AgentCapabilities;
    fn availability(&self) -> AvailabilityStatus;
}
Expand description

Core executor trait implemented by all providers.

The trait intentionally models only common behavior. Provider-specific advanced features should be layered outside this trait to keep API parity predictable.

§Examples

use std::path::Path;
use unified_agent_sdk::{AgentExecutor, executor::SpawnConfig};

async fn run_prompt(executor: &dyn AgentExecutor) -> unified_agent_sdk::Result<()> {
    let session = executor
        .spawn(
            Path::new("."),
            "Summarize this repository.",
            &SpawnConfig {
                model: None,
                reasoning: Some("medium".to_string()),
                permission_policy: None,
                env: Vec::new(),
                context_window_override_tokens: None,
            },
        )
        .await?;

    let _metadata = session.metadata();
    Ok(())
}

Required Methods§

Source

fn executor_type(&self) -> ExecutorType

Returns the provider type implemented by this executor.

Source

fn spawn<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, working_dir: &'life1 Path, prompt: &'life2 str, config: &'life3 SpawnConfig, ) -> Pin<Box<dyn Future<Output = Result<AgentSession>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Starts a fresh session and sends prompt as the first turn.

working_dir should point to the repository/workspace where tools and file operations are expected to run.

Source

fn resume<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, working_dir: &'life1 Path, prompt: &'life2 str, session_id: &'life3 str, reset_to: Option<&'life4 str>, config: &'life5 SpawnConfig, ) -> Pin<Box<dyn Future<Output = Result<AgentSession>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait,

Resumes a previously created session and sends a follow-up prompt.

session_id is the provider-native identifier returned by a previous session. reset_to is optional and only supported by providers that expose rewind/reset semantics.

Source

fn capabilities(&self) -> AgentCapabilities

Returns static capability flags for this executor implementation.

Source

fn availability(&self) -> AvailabilityStatus

Performs a lightweight availability check for required runtime dependencies.

Implementors§