pub trait ToolExecutor: Send + Sync {
// Required method
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool: &'life1 str,
params: &'life2 Value,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
// Provided methods
fn execute_with_action<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tool: &'life1 str,
params: &'life2 Value,
_action_id: &'life3 str,
_timeout_ms: Option<u64>,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
fn execute_with_action_in_session<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
tool: &'life1 str,
params: &'life2 Value,
action_id: &'life3 str,
timeout_ms: Option<u64>,
_session_id: Option<&'life4 str>,
_attempt: u32,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait { ... }
fn execute_with_action_state_in_session<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'life6, 'async_trait>(
&'life0 self,
tool: &'life1 str,
params: &'life2 Value,
action_id: &'life3 str,
timeout_ms: Option<u64>,
session_id: Option<&'life4 str>,
attempt: u32,
_expected_effects: &'life5 HashMap<String, Value>,
_return_schema: Option<&'life6 Value>,
) -> Pin<Box<dyn Future<Output = Result<ToolExecution, String>> + 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,
'life6: 'async_trait { ... }
fn execute_classified<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'life6, 'async_trait>(
&'life0 self,
tool: &'life1 str,
params: &'life2 Value,
action_id: &'life3 str,
timeout_ms: Option<u64>,
session_id: Option<&'life4 str>,
attempt: u32,
expected_effects: &'life5 HashMap<String, Value>,
return_schema: Option<&'life6 Value>,
) -> Pin<Box<dyn Future<Output = Result<ToolExecution, ToolFailure>> + 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,
'life6: 'async_trait { ... }
fn execute_stream<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tool: &'life1 str,
_params: &'life2 Value,
_action_id: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<Receiver<ToolStreamChunk>, String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
}Expand description
Trait for tool execution. Implement this to provide tools to the runtime.
In-process: implement directly with function calls. Daemon mode: implement by sending JSON-RPC to the client.
Required Methods§
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool: &'life1 str,
params: &'life2 Value,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Provided Methods§
Sourcefn execute_with_action<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tool: &'life1 str,
params: &'life2 Value,
_action_id: &'life3 str,
_timeout_ms: Option<u64>,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn execute_with_action<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tool: &'life1 str,
params: &'life2 Value,
_action_id: &'life3 str,
_timeout_ms: Option<u64>,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Variant that also carries the originating proposal Action.id
and its timeout_ms budget.
action_id: WS-based executors (car-server-core::WsToolExecutor)
use it so the daemon-initiated tools.execute request to the client
carries the same id the host’s process-wide handler is keyed on
— without this round-trip the host can’t disambiguate concurrent
callbacks for the same tool (Parslee-ai/car-releases#43 follow-up).
timeout_ms: the action’s per-call budget. WS executors MUST bound
their callback wait by this (falling back to a default when None)
so the daemon→host wait and the executor’s own action deadline stay
coordinated — otherwise a hardcoded inner wait reaps a call the outer
deadline still permits (Parslee-ai/car#259). In-process executors
that don’t need either can keep the default forward to execute.
Sourcefn execute_with_action_in_session<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
tool: &'life1 str,
params: &'life2 Value,
action_id: &'life3 str,
timeout_ms: Option<u64>,
_session_id: Option<&'life4 str>,
_attempt: u32,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn execute_with_action_in_session<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
tool: &'life1 str,
params: &'life2 Value,
action_id: &'life3 str,
timeout_ms: Option<u64>,
_session_id: Option<&'life4 str>,
_attempt: u32,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Variant that also carries the Runtime execution session and the retry attempt. Executors that retain safety-relevant state across calls (such as a read-before-edit ledger) override this to keep that state isolated by session. Existing executors retain their current behavior through the default delegation.
attempt is 1-based: 1 on the first try, 2 on the first retry.
WS executors surface it on the tools.execute payload so a host can
tell which retry it is serving — action_id cannot, being neither
unique across attempts nor varying between them.
It is threaded from execute_with_retry’s own counter rather than
synthesized here. It was previously hardcoded to 1 at the one place
that put it on the wire, which made the field a constant and any join
built on it silently degenerate (Parslee-ai/car#928).
Sourcefn execute_with_action_state_in_session<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'life6, 'async_trait>(
&'life0 self,
tool: &'life1 str,
params: &'life2 Value,
action_id: &'life3 str,
timeout_ms: Option<u64>,
session_id: Option<&'life4 str>,
attempt: u32,
_expected_effects: &'life5 HashMap<String, Value>,
_return_schema: Option<&'life6 Value>,
) -> Pin<Box<dyn Future<Output = Result<ToolExecution, String>> + 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,
'life6: 'async_trait,
fn execute_with_action_state_in_session<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'life6, 'async_trait>(
&'life0 self,
tool: &'life1 str,
params: &'life2 Value,
action_id: &'life3 str,
timeout_ms: Option<u64>,
session_id: Option<&'life4 str>,
attempt: u32,
_expected_effects: &'life5 HashMap<String, Value>,
_return_schema: Option<&'life6 Value>,
) -> Pin<Box<dyn Future<Output = Result<ToolExecution, String>> + 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,
'life6: 'async_trait,
Execute one action while allowing a transport to return runtime-observed state mutations alongside its ordinary tool output.
The default preserves every direct/internal executor: its existing
output is wrapped with no mutations, and declared expected_effects
remain assertions rather than writes. A transport that overrides this
method must validate its mutation envelope against expected_effects
before returning. The Runtime repeats the key-set and I-JSON checks and
applies accepted changes through its own StateStore.
Sourcefn execute_classified<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'life6, 'async_trait>(
&'life0 self,
tool: &'life1 str,
params: &'life2 Value,
action_id: &'life3 str,
timeout_ms: Option<u64>,
session_id: Option<&'life4 str>,
attempt: u32,
expected_effects: &'life5 HashMap<String, Value>,
return_schema: Option<&'life6 Value>,
) -> Pin<Box<dyn Future<Output = Result<ToolExecution, ToolFailure>> + 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,
'life6: 'async_trait,
fn execute_classified<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'life6, 'async_trait>(
&'life0 self,
tool: &'life1 str,
params: &'life2 Value,
action_id: &'life3 str,
timeout_ms: Option<u64>,
session_id: Option<&'life4 str>,
attempt: u32,
expected_effects: &'life5 HashMap<String, Value>,
return_schema: Option<&'life6 Value>,
) -> Pin<Box<dyn Future<Output = Result<ToolExecution, ToolFailure>> + 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,
'life6: 'async_trait,
Execute one action with typed failure evidence.
This is a new default-delegating layer rather than a signature change
to the existing execution methods. Existing executors therefore retain
their exact behavior: every legacy string error becomes an ordinary,
non-terminal failure. Executors opt into fail-stop behavior only by
overriding this method and returning ToolFailure::terminal.
Sourcefn execute_stream<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tool: &'life1 str,
_params: &'life2 Value,
_action_id: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<Receiver<ToolStreamChunk>, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn execute_stream<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tool: &'life1 str,
_params: &'life2 Value,
_action_id: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<Receiver<ToolStreamChunk>, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Streaming entry point for detached invocation modes (C2). Start
the tool and return a channel of car_ir::ToolStreamChunks; the
runtime drains it into the per-runtime handle registry while the
DAG proceeds. End the stream with a terminal chunk (done /
error); dropping the sender without one is reported as failure.
A cooperative executor should stop work when the receiver returned
here is dropped (that’s what cancellation looks like from its side).
Default: unsupported — existing one-shot executors compile and behave unchanged; a detached action against them is rejected with this error.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".