tool

Attribute Macro tool 

Source
#[tool]
Expand description

Transforms a function into a Strands agent tool.

§Example

use strands::tool;

#[tool]
/// Get the current weather for a location.
async fn get_weather(location: String, units: Option<String>) -> String {
    format!("Weather in {}: 72°F", location)
}

The generated tool can be used with an agent:

let agent = Agent::builder()
    .model(BedrockModel::default())
    .tools(vec![GetWeatherTool::new()])
    .build()?;