Skip to main content

execute

Function execute 

Source
pub fn execute(
    tool: &ScriptTool,
    args: Value,
    host: Arc<dyn ScriptHost>,
) -> String
Expand description

Execute a compiled script tool with the model-supplied args, returning the result as a string for the agent. args is exposed to the script as the params object-map. The returned Rhai value is serialized to JSON unless it is already a string (returned verbatim). Any script error becomes an [error] … string.

A panic raised by a native (host) function never unwinds through this call: it is caught at the native-function boundary by guard_str/guard_dyn and arrives here as an ordinary script error. Anything that still escapes - a panic from Rhai’s own internals - is contained one level up, where the daemon runs this on a spawn_blocking task and turns the resulting JoinError into a tool error.