pub trait Callable: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn run<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn description(&self) -> Option<&str> { ... }
fn run_streaming<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 str,
event_tx: Sender<StreamEvent>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn last_usage(&self) -> Option<LlmTokenUsage> { ... }
}Expand description
Core Callable trait - the fundamental execution unit
Everything that can be “run” implements this trait:
- LLM agents
- Graph nodes
- Tools (when wrapped)
- Flow compositions
§Design Principles
- Simple: Just run with input, get output
- Async: All execution is async by default
- Named: Every callable has a name for logging/debugging
- Composable: Callables can wrap other callables
Required Methods§
Sourcefn run<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn run<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute the callable with the given input
This is the core execution method. Implementations should:
- Be idempotent when possible
- Handle their own retries if needed
- Return meaningful error messages
Provided Methods§
Sourcefn description(&self) -> Option<&str>
fn description(&self) -> Option<&str>
Callable description (optional, for documentation)
Sourcefn run_streaming<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 str,
event_tx: Sender<StreamEvent>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn run_streaming<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 str,
event_tx: Sender<StreamEvent>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute with streaming events forwarded to the given sender.
Default implementation ignores the sender and calls run().
LLM/agent callables should override to poll their event emitter
and forward events to event_tx while running.
Sourcefn last_usage(&self) -> Option<LlmTokenUsage>
fn last_usage(&self) -> Option<LlmTokenUsage>
Token usage from the last successful run, if available.
LLM-backed callables may set this from provider usage metadata;
others return None. The runner uses this for accurate cost tracking
when present, otherwise falls back to estimates.