Skip to main content

NativeSkill

Trait NativeSkill 

Source
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§

Source

fn name(&self) -> &str

Unique tool name. Must be globally unique across both native and MCP tools.

Source

fn description(&self) -> &str

Human-readable description of what the tool does.

Source

fn parameters_schema(&self) -> Value

JSON Schema describing the expected input parameters.

Source

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,

Execute the tool with the given arguments and return the result.

Provided Methods§

Source

fn effect(&self) -> ToolEffect

Declared effect used for scheduling. Undeclared legacy skills fail closed to ToolEffect::Unknown.

Source

fn approval_class(&self) -> ApprovalClass

Descriptor-level approval classification.

Source

fn sandbox_required(&self) -> bool

Whether this skill must execute in a sandbox.

Source

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.

Source

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.

Source

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.

Source

fn concurrency_key(&self) -> Option<&str>

Optional key used to serialize conflicting read-only operations.

Source

fn exposure(&self) -> Exposure

Model and host exposure class.

Source

fn output_limit(&self) -> Option<TruncationPolicy>

Descriptor-specific model-visible output bound.

Source

fn source(&self) -> ToolSource

Registration source. Built-in runtime tools override this value.

Source

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.

Source

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.

Source

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.

Source

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".

Implementors§