pub trait NativeSkill: Send + Sync {
Show 18 methods
// Required methods
fn name(&self) -> &str;
fn description(&self) -> &str;
fn parameters_schema(&self) -> Value;
fn execute<'life0, 'async_trait>(
&'life0 self,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn effect(&self) -> ToolEffect { ... }
fn approval_class(&self) -> ApprovalClass { ... }
fn sandbox_required(&self) -> bool { ... }
fn supports_sandbox_execution(&self) -> bool { ... }
fn check_thread_policy(&self, _policy: &ThreadPolicy) -> Result<()> { ... }
fn sandbox_request(&self, _args: Value) -> Result<ExecutionRequest> { ... }
fn concurrency_key(&self) -> Option<&str> { ... }
fn exposure(&self) -> Exposure { ... }
fn output_limit(&self) -> Option<TruncationPolicy> { ... }
fn source(&self) -> ToolSource { ... }
fn execute_with_context<'life0, 'life1, 'async_trait>(
&'life0 self,
args: Value,
_context: &'life1 NativeExecutionContext,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn take_canonical_receipt_data(
&self,
_result: &mut Value,
) -> Result<NativeCanonicalReceiptData> { ... }
fn result_artifacts(
&self,
_result: &Value,
) -> Result<Vec<ToolOutputArtifact>> { ... }
fn format_result(
&self,
result: &Value,
policy: TruncationPolicy,
model: &str,
) -> String { ... }
}Expand description
Trait for embedding high-performance Rust tool implementations directly into the runtime binary.
Native skills bypass MCP serialization and execute in-process, making them ideal for latency-sensitive operations like system introspection, caching lookups, or internal state queries.
Required Methods§
Sourcefn name(&self) -> &str
fn name(&self) -> &str
Unique tool name. Must be globally unique across both native and MCP tools.
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Human-readable description of what the tool does.
Sourcefn parameters_schema(&self) -> Value
fn parameters_schema(&self) -> Value
JSON Schema describing the expected input parameters.
Provided Methods§
Sourcefn effect(&self) -> ToolEffect
fn effect(&self) -> ToolEffect
Declared effect used for scheduling. Undeclared legacy skills fail
closed to ToolEffect::Unknown.
Sourcefn approval_class(&self) -> ApprovalClass
fn approval_class(&self) -> ApprovalClass
Descriptor-level approval classification.
Sourcefn sandbox_required(&self) -> bool
fn sandbox_required(&self) -> bool
Whether this skill must execute in a sandbox.
Sourcefn supports_sandbox_execution(&self) -> bool
fn supports_sandbox_execution(&self) -> bool
Whether this implementation has an adapter for the host’s sandbox protocol. A code-execution effect is not evidence of an adapter.
Sourcefn check_thread_policy(&self, _policy: &ThreadPolicy) -> Result<()>
fn check_thread_policy(&self, _policy: &ThreadPolicy) -> Result<()>
Admit direct execution under a captured child policy. Implementations must enforce any authority they consume, not merely declare ReadOnly.
§Errors
Unported tools cannot silently inherit an unrestricted host execution path. Sandbox execution uses the host’s separate physical binding.
Sourcefn sandbox_request(&self, _args: Value) -> Result<ExecutionRequest>
fn sandbox_request(&self, _args: Value) -> Result<ExecutionRequest>
Translate validated arguments into this tool’s actual sandbox operation. The host must not guess executable code or language from field/tool names.
§Errors
The default rejects tools without an explicit sandbox adapter. Implementors must preserve argument semantics and reject unsupported execution modes.
Sourcefn concurrency_key(&self) -> Option<&str>
fn concurrency_key(&self) -> Option<&str>
Optional key used to serialize conflicting read-only operations.
Sourcefn output_limit(&self) -> Option<TruncationPolicy>
fn output_limit(&self) -> Option<TruncationPolicy>
Descriptor-specific model-visible output bound.
Sourcefn source(&self) -> ToolSource
fn source(&self) -> ToolSource
Registration source. Built-in runtime tools override this value.
Sourcefn execute_with_context<'life0, 'life1, 'async_trait>(
&'life0 self,
args: Value,
_context: &'life1 NativeExecutionContext,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute_with_context<'life0, 'life1, 'async_trait>(
&'life0 self,
args: Value,
_context: &'life1 NativeExecutionContext,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute with host context only after schema validation and governance. Implementations without contextual behavior retain their existing path.
Sourcefn take_canonical_receipt_data(
&self,
_result: &mut Value,
) -> Result<NativeCanonicalReceiptData>
fn take_canonical_receipt_data( &self, _result: &mut Value, ) -> Result<NativeCanonicalReceiptData>
Remove host-only raw-stream metadata from a successful typed result. Ordinary native skills have no separate byte streams.
Sourcefn result_artifacts(&self, _result: &Value) -> Result<Vec<ToolOutputArtifact>>
fn result_artifacts(&self, _result: &Value) -> Result<Vec<ToolOutputArtifact>>
Declare structured outputs from a successful result, before truncation. The trusted host owns publication; ordinary tools produce no artifacts.
Sourcefn format_result(
&self,
result: &Value,
policy: TruncationPolicy,
model: &str,
) -> String
fn format_result( &self, result: &Value, policy: TruncationPolicy, model: &str, ) -> String
Format one successful result for model-visible history.
The default preserves the existing JSON representation and applies the run’s output policy at the single history-ingest boundary. Native tools whose raw output needs format-aware truncation may override this method.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".