Skip to main content

RuntimeAdapter

Trait RuntimeAdapter 

Source
pub trait RuntimeAdapter: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn has_shell_access(&self) -> bool;
    fn has_filesystem_access(&self) -> bool;
    fn storage_path(&self) -> PathBuf;
    fn supports_long_running(&self) -> bool;
    fn build_shell_command(
        &self,
        command: &str,
        workspace_dir: &Path,
    ) -> Result<Command>;

    // Provided method
    fn memory_budget(&self) -> u64 { ... }
}
Expand description

Runtime adapter that abstracts platform differences for the agent.

Implement this trait to port the agent to a new execution environment. The adapter declares platform capabilities (shell access, filesystem, long-running processes) and provides platform-specific implementations for operations like spawning shell commands. The orchestration loop queries these capabilities to adapt its behavior—for example, disabling tool execution on runtimes without shell access.

Implementations must be Send + Sync because the adapter is shared across async tasks on the Tokio runtime.

Required Methods§

Source

fn name(&self) -> &str

Return the human-readable name of this runtime environment.

Used in logs and diagnostics (e.g., "native", "docker", "cloudflare-workers").

Source

fn has_shell_access(&self) -> bool

Report whether this runtime supports shell command execution.

When false, the agent disables shell-based tools. Serverless and edge runtimes typically return false.

Source

fn has_filesystem_access(&self) -> bool

Report whether this runtime supports filesystem read/write.

When false, the agent disables file-based tools and falls back to in-memory storage.

Source

fn storage_path(&self) -> PathBuf

Return the base directory for persistent storage on this runtime.

Memory backends, logs, and other artifacts are stored under this path. Implementations should return a platform-appropriate writable directory.

Source

fn supports_long_running(&self) -> bool

Report whether this runtime supports long-running background processes.

When true, the agent may start the gateway server, heartbeat loop, and other persistent tasks. Serverless runtimes with short execution limits should return false.

Source

fn build_shell_command( &self, command: &str, workspace_dir: &Path, ) -> Result<Command>

Build a shell command process configured for this runtime.

Constructs a tokio::process::Command that will execute command with workspace_dir as the working directory. Implementations may prepend sandbox wrappers, set environment variables, or redirect I/O as appropriate for the platform.

§Errors

Returns an error if the runtime does not support shell access or if the command cannot be constructed (e.g., missing shell binary).

Provided Methods§

Source

fn memory_budget(&self) -> u64

Return the maximum memory budget in bytes for this runtime.

A value of 0 (the default) indicates no limit. Constrained environments (embedded, serverless) should return their actual memory ceiling so the agent can adapt buffer sizes and caching.

Implementors§