Skip to main content

tool_function

Macro tool_function 

Source
macro_rules! tool_function {
    (|$input:ident: Value| $body:expr) => { ... };
}
Expand description

Helper macro for creating simple tool functions.

§Example

use agentik_sdk::tool_function;
use serde_json::{json, Value};

let weather_tool = tool_function!(|input: Value| async move {
    let location = input["location"].as_str().unwrap_or("Unknown");
    let result = format!("Weather in {}: 72°F and sunny", location);
    Ok(agentik_sdk::ToolResult::success("tool_id", result))
});