pub struct CodeExecutionTool { /* private fields */ }Expand description
Code execution tool.
This tool allows agents to execute code in a sandboxed environment. It requires integration with an external code execution service.
§Safety
Code execution is inherently dangerous. This tool should:
- Always run in a sandboxed environment
- Have strict resource limits
- Only be used with trusted agents
§Example
ⓘ
use serdes_ai_tools::builtin::{CodeExecutionTool, CodeExecutionConfig, ProgrammingLanguage};
let tool = CodeExecutionTool::with_config(
CodeExecutionConfig::new()
.timeout_secs(10)
.allowed_languages(vec![ProgrammingLanguage::Python])
);Implementations§
Source§impl CodeExecutionTool
impl CodeExecutionTool
Sourcepub fn with_config(config: CodeExecutionConfig) -> Self
pub fn with_config(config: CodeExecutionConfig) -> Self
Create with a specific config.
Trait Implementations§
Source§impl Debug for CodeExecutionTool
impl Debug for CodeExecutionTool
Source§impl Default for CodeExecutionTool
impl Default for CodeExecutionTool
Source§impl<Deps: Send + Sync> Tool<Deps> for CodeExecutionTool
impl<Deps: Send + Sync> Tool<Deps> for CodeExecutionTool
Source§fn definition(&self) -> ToolDefinition
fn definition(&self) -> ToolDefinition
Get the tool’s definition. Read more
Source§fn call<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 RunContext<Deps>,
args: JsonValue,
) -> Pin<Box<dyn Future<Output = ToolResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn call<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 RunContext<Deps>,
args: JsonValue,
) -> Pin<Box<dyn Future<Output = ToolResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute the tool with given arguments. Read more
Source§fn prepare<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 RunContext<Deps>,
def: ToolDefinition,
) -> Pin<Box<dyn Future<Output = Option<ToolDefinition>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn prepare<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 RunContext<Deps>,
def: ToolDefinition,
) -> Pin<Box<dyn Future<Output = Option<ToolDefinition>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Prepare the tool definition at runtime. Read more
Source§fn description(&self) -> String
fn description(&self) -> String
Get the tool description.
Auto Trait Implementations§
impl Freeze for CodeExecutionTool
impl RefUnwindSafe for CodeExecutionTool
impl Send for CodeExecutionTool
impl Sync for CodeExecutionTool
impl Unpin for CodeExecutionTool
impl UnwindSafe for CodeExecutionTool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more